Well when I get those types of thoughts, it really helps me to write everything down in a journal, or anything really, so long as I'm putting it on paper and expressing myself. It doesn't even have to be about the problem itself; it can be about anything you want to write that will get your mind off of it. I like to write stories to distract me when I'm down sometimes. c:
But anything works, like art, music, movies, etc.
I also try to talk to people if I can, because it can be helpful for me to be around others and laugh if I'm having those thoughts that won't go away.
I hope you find something that helps you!