If you get short bursts of these thoughts, they can be more easily dealt with, just affect your environment. Do something to cheer you up, whether it's happy music, going outside, watching something funny. I always think, the length of time a thought is in your head, that's the same length of time of not thinking about it that will be required for you to forget it.
And don't feel bad to treat yourself. This is something I only learned in the last month or so. If you feel depressed, don't try and push through that essay/work project, take a break and enjoy yourself, it's better than letting the depression continue.