Let your thoughts pass
Your thoughts are temporary, just like your emotions. In other words, even if it feels endless and unbearable, you must understand that it will finally pass. It ultimately shouldn’t matter if you don't dwell on your thoughts.
Although it's more difficult than it seems, resist the urge to act upon your intrusive thoughts. Recognize that the bulk of these thoughts are incorrect and come from worry and fear. Simply let them pass, and soon they will go. Obsessing and focusing on such ideas, though, will just make them more likely to occur. The more you can free yourself from your ideas, the better. Keep in mind that "This too shall pass" or “My thoughts are temporary”. There are simple but effective mantras that might help you in regaining perspective.