Yes, it can immediately move away.
PHB, page 196, Movement and Position
However you’re moving, you deduct the
distance of each part of your move from your speed until
it is used up or until you are done moving.
So if you have someone grappled, and they use their action to escape the grapple, their speed is no longer forcibly set to 0. As a result, their speed is their base speed + / - modifiers, and they can continue to move unhampered.
It's worth noting, though, that they would not be able to take a disengage action without extra actions or features, so if they run away you would get an opportunity attack.
At it's core, your question is whether or not it is the speed you begin your turn with that matters. As a more intuitive example, a wizard who casts Expeditious Retreat on themselves would expect to be able to move more quickly that turn, which is the same core principle as your scenario.