You can't completely shut off stray thoughts. But these will help reduce them...
- Increase difficulty: Tasks that are nearly automated and require little mental effort from your side are mind-wandering incubators. Increase the difficultly of the task.
- Social pressure: Put yourself in front of others. The social stress and the fear of being publicly ashamed will arm you with the power to focus.
- Journaling: The best way to get current or past problems off your head is writing them down. The act of writing what needs to be done will liberate you from the constant thoughts.
- Meta-awareness: The faster you “catch” yourself drifting, the faster you'll bring your mind back to the task at hand. When you realize that you're zoning out, you can write down what you're thinking about on a piece of paper and move on with your task.
- Mindfulness training: Researchers show that this is one of the best ways to reduce the constant buzzing thoughts and train your mind to concentrate for longer periods of time.
- Remove distractions: The easiest way to reduce the amount of not-related thoughts is by removing distractions from your work environment.