Puzzles in general
It is often close to impossible to make a brainteaser-logic puzzle bullet-proof without ruining it. A certain amount of loop-holes is, what keeps the puzzles interesting after all.
The real question then is, how to deal with loop-holes and brain-teaser puzzles as a puzzle author. I would recommend the following guidelines:
State that you do not seek for some extra-clever loop-hole answer, but for an answer within the framework of the puzzle.
Depending on the type of puzzle, this is more or less difficult, but such a statement
- Indicates you're serious about this puzzle.
- Gives you a handhold against wild-guesses.
Change your viewpoint. Try to solve your puzzle with loop-holes. If one is found, decided if it is a 'reasonable' or a very 'obscure' one, and safe-guard accordingly.
If there are loopholes just because some statements can be misinterpreted or are missing, then fix the text accordingly.
Example: A recent example is this puzzle. It omits an important statement, that questions are truthfully answered, and it does not clearly define what is meant by being known. This opens up to loop-hole answers, and could very easily be avoided.
Counter-Example: In the same puzzle, one could creatively construct a rather obscure loop-hole that Dr. No is the person watching the party from the security cameras only. This is clearly outside the original puzzle-scope and it is not worthwhile to safeguard against such answers. (Except by the general statement.)
Double or Triple-check your logic. Is it really 'tight' ?
It can be helpful to ask the puzzle to another person with and without giving your intended answer. A second opinion can be very helpful.
Puzzles on PuzzlingSE
The three points above are generally helpful, but on the other hand, PuzzlingSE is (also) about learning if your puzzle works or not. So maybe the real question is less on how to avoid the situation than on how to deal with it.
React positively on comments and loop-hole answers.
Somebody spotted a weak point in your puzzle - that's great news! It allow making it better by fixing it! Take the comment/solution seriously. If it is just a joke or very obscure - tell the poster and otherwise ignore. If it is, however, justifiable, then follow the next advise:
Edit your question to improve.
Whenever you think that you've spotted a better way to present your puzzle - make that edit! PuzzlingSE is not 'fun for the moment', but it's ultimate goal is to be useful (and searchable) for future readers. Even if you've already got an accepted answer, if you find a way to make your original post better then do it.
If this edit changes the puzzle drastically or makes some of the existing answers look strange, make the edit visible as an edit and/or add an according comment to the existing answers.