You don't have to stop thinking about bad things. You just need to start filling your mind with good things.
"The ultimate freedom we have as human beings is the power to select what we will allow or require our minds to dwell upon." - Dallas Willard
"The presence of God is not the absence of troubles, but the confidence that He is with us in them." - CS Lewis
"You will keep in perfect peace those whose minds are steadfast, because they trust in you." - Isaiah 26:3