New to 529 Distribution and .. yeah .. your advice needed!

Can someone clarify this? I’ve read that if it turns out student gets a scholarship and doesn’t use or, at least, deplete 529 funds, student can withdraw without the 10% penalty (though must pay taxes on gains). Does this have to be done right away or can we wait until grad sch/career plans are finalized? I’m thinking leave the funds there (to grow) until certain that kid isn’t going to need them for more school. But if 10% penalty will be incurred later, I’d rather do withdrawal before knowing about grad sch. Hope that makes sense.