Page 195 of the PHB.
"You can make an opportunity attack when a hostile creature that you can see moves out of your reach"
You only get it if they actually move out of your reach. Yes, you attack before they leave, but unless they move out of reach there is no AOO at all. It does not say, "attempts to move out of your reach."
It it also says, "The attack occurs right before the creature leaves your reach."
Right before it LEAVES REACH. Not, "If it never leaves reach." The "before it leaves reach" means that it is still leaving reach.