How to change what we think?


I have a hard time changing what I am thinking.
During the day, I try to stop thinking when I think to something that I don’t like and I distract me to move on something else.
During the night, it’s like all what I stopped during the day comes back like a boomerang. It wakes me up and I cannot go back to sleep.
What can I do?