I struggle with this too
I guess when you notice that you are getting mild thoughts you should try to do somethig to distract yourself so they don't develop into something more. That could be anything from listening to your favourite music, watching a film, other things you might enjoy.
I used to have a whole list of distraction techniques but lost it unfortunately.