Whether the questioner later realised the answer is not in fact relevant to whether the question should be closed/deleted. The fact that you think of the answer an hour after posting may make you feel as if the question was pointless, but (unless you merely failed to check a dictionary) your question may help others in the future: post the answer, and you may get a 'Self-Learner' badge.
Conversely, what seemed like a good question in your head may, once you have formalized it sufficiently to ask on ELU, turn out to be trivial; I understand programmers call this rubber duck debugging, though sensible teachers have known it for centuries. If so, best to delete it before it is downvoted or deleted. (In theory, you could get upvotes for your answer and gain a 'Reversal' badge'; but it doesn't apply to closures, and in point of fact ELU has not awarded any Reversal badges).
From an outsider's point of view, I suggest a rule of thumb; would you, after the question has been improved, be happy for it to go out over your name? If so, go ahead and edit. If not (and the example would get a definite 'No' from most people), then flag for a mod to close, closevote, or vote to delete, depending on your reputation.