Aetheri
W/E happens don't panic...
Recognizing when these thoughts occur may help. Its usually a result of your subconcious mind taking over from your concious mind. When you recognize the occurance of such thoughts as part of your subconcious you are able to turn them into concious thoughts, which you are more capable of controlling.I hate it when the thoughts in my head get out of hand...
Practicing meditation can make this a lot easier.