In her book Bird by Bird, Anne Lamott talks about how she shuts out distractions when she is writing:
Close your eyes and get quiet for a minute, until the chatter starts up. Then isolate one of the voices and imagine the person speaking as a mouse. Pick it up by the tail and drop it into a mason jar. Then isolate another voice, pick it up by the tail, drop it in the jar. And so on. Drop in any high-maintenance parental units, drop in any contractors, lawyers, colleagues, children, anyone who is whining in your head. Then put the lid on, and watch all these mouse people clawing at the glass, jabbering away trying to make you feel like shit because you won't do what they want -- won't give them more money, won't be more successful, won't see them more often. Then imagine that there is a volume-control button on the bottle. Turn it all the way up for a minute, and listen to the stream of angry, neglected, guilt-mongering voices. Then turn it all the way down and watch the frantic mice lunge at the glass, trying to get to you. Leave it down and get back to your shitty first draft.A friend of mine uses visualization, similar to Lamott, but her ideas isn't quite as dramatic. She says that if she has a distracting thought that comes up over and over again, she does the following. She visualizes the distracting thought as a piece of trash, walks over to the trash can, and throws it in the trash can.
A while ago, I was in a very stressful, busy situation. I was doing a master's thesis, taking classes, and applying to grad school -- all at the same time. I was starting to obsess over a person in my life, but I had zero time to be distracted like that. So I used the following method. I would carry an index card in my pocket. When I had the distracting thought, I would record a tally mark on the card and stick it back in my pocket. This method worked for me. Unlike the first two methods, which involve visualizing everything in your mind's eye, the method I describe is physical. You could look at how many tally marks you have at the end of the day, to assess how you're doing. You could see how distracted you are, or how much you've improved.