It's a matter of how well you can self-regulate your thought patterns and emotions. It's difficult at first, but can get easier with practice and time. Try if you can just stop whatever it is you're doing (in my case, I actually say "stop!" to myself out loud), and question whether what you're doing is productive or not. Think about how you'll feel at the end of the day when you go to sleep if you continue with these distracting thoughts and don't get anything done (probably disappointed and regretful) vs. how you'll feel if you completed whatever needed to be done (accomplishment and relief). You can go as far as to form a mental image of yourself feeling that accomplishment, or recall past times where you got heaps of stuff done and felt good about it. Now is an opportunity to recreate that. And then when you finish what you set out to do, you can reward yourself. Or if that desire to return to those thoughts is just too irresistible, at least now you can return to those thoughts guilt free because at least you had a productive day.
Alternatively, if you're actually really burnt out from stress, I guess you could do some exercise, a hobby, mindfulness meditation or a brief nap to get those thoughts under control, and then try to return to whatever you need to do.