I am sorry you are having such difficulty with your thoughts. It is very hard for any of us to get rid of a disturbing thought like this, even if anxiety is not strongly present.
When these types of thoughts occur they are technically called obsessions. This particular one is a thought that brings you great anxiety and probably makes you feel terrible about yourself. Know that although you have these thoughts it is not a reflection of who you are. In fact, it is a very biochemical process.
A part of your brain, called the anterior cingulate gyrus starts most of our thoughts. It is then sent to the prefontal cortex to be processed further. With those who have anxiety, the prefrontal cortex fails to resolve the thought and it then sends it back to the originating part of the brain causing a loop, a cycle. It then repeats causing anxiety. This is not your fault, at all, and it is creating a pattern pathway that can be stopped.
An increase of serotonin, a neurotransmitter in the brain, can often stop this pattern. 1000mg of Omega 3, 100mg magnesium glycinate and 10 mg zinc and 100 mg calcium can often assist in this process, naturally. You should ask your doctor if you can take these supplements as they can interfere with some prescription drugs effectiveness.
Also the resource, The Anxiety and Phobia Workbook by Edmund Bourne is valuable for all those who suffer from anxiety. It is excellent and very inexpensive on amazon.com It gives very practical and detailed information on how to deal with these types of thoughts, far more than can be detailed here on Just Answer.
You can feel better from this and these methods do work.
Please try them. I think you will be surprised at the effectiveness of these methods. Steven