I would suggest voting to close these posts as off-topic, with a comment letting the user know that the problem was caused by a syntax error and will not be helpful to future visitors.
Danny Beckett is right, "too localized" did indeed cover these cases, but too many people misunderstand that "too localized" doesn't have anything to do with location. However, that doesn't make these syntax error questions on-topic or useful.
It may even be a good idea to try and add another custom off-topic close reason specifically for syntax errors, as I can't really see a case where those types of questions would be useful, and this particular close reason would be less likely to be misunderstood as having to do with a place.
As for cases where someone posted a question and then had that moment of realization that the answer is fully within their grasp, we must step back and take a look at the question on its own merits. Is the question well-written? Does the question clearly describe the problem and include information that would help others with the same problem relate to it? If there are answers, are they high quality? In short, would a person with the same or similar problem benefit from the material if he or she found the site from a Google search?
If the question is valuable, it shouldn't be closed. The point of Stack Overflow is not just to help the asker but to also help the thousands of future visitors out there who have the same or a similar problem.
With that said, the asker may benefit from what Jeff Atwood calls Rubber Duck Problem Solving. Sometimes, the act of actually writing out your question, with all of the details, what you've tried, what errors you're getting, and any other relevant information, oftentimes helps a person find the answer to the problem.
Arguably, as long as a question is good for Stack Overflow, this isn't a bad way to work through your problems, assuming one writes very good questions that "give back" to the community and that, if there are no answers, the asker returns to post a nice, well-written, detailed self-answer.