Thanks for using JustAnswer!
It sounds like you may be having some OCD. I would recommend seeing a psychiatrist and therapist. A psychiatrist will be able to provide you some medications to help reduce your anxiety and stress which in turn should help reduce the repetative thinking. A therapist will help you work through what is going on and help you learn to manage your stress. In the meantime I would write down whatever is playing over and over in your head. Sometimes that helps and when you stop trying to not think about it and you allow your self to think about it, it can help.
I hope this helps. I am here to provide you with a satisfactory answer. Please let me know if I can assit anymore.