Thanks for your query. These repeated/unwanted thoughts are chaacteristic of OCD/Obsessive compulsive disorder
. The treatment consists of:
1. Anti-obsessive agents like fluoxetine/clomipramine
techniques like ERP/exposure and response prevention
A combination therapy always works better than either of them alone. Wish you good health.