Here is a powerful dua to stop evil thoughts that come into our heads from time to time. It will also stop negative thoughts of any kind.
اللهم اطفئ نار الشهوات من قلبى ، واصرف عنه كل شئ لا يرضيك عنى
Allahumma iTfa’ naara ash-shahawaati min qalbee, wa aSrif 3anhu kulla shay’ la yardeeka Annni
Oh Allah! Extinguish the fire of desires in my heart and redirect my heart to all that which pleases you.