When it happens, notice the negative thinking pattern, label it, and let it float away. Decide to stop dwelling on the idea.
Source: To Change a Hurtful Mental Habit, Make ‘The 4 Decisions’ @ Psychology Today
Photo: I have a bright idea! by Nic Taylor under Creative Commons license