Years ago I heard someone, possibly on NPR's Fresh Air, talking about how thoughts were a lot like food: just as we can make decisions about what we eat - "no, I am not going to eat that (now|today|ever)" - we can also learn to identify thoughts that have negative effects on us and when they happen we can choose not to think them.
At the time, this sounded a bit fanciful and just a bit ridiculous to me. Over the decades since, it has come to be one of my foundational philosophies. Obviously, I am unable to stick to it all the time, just as I sometimes eat food that I know is going to make me feel bad. But it's there as a guiding principle, all the time.