Taking the mind off the problem is one way, but subconsciously you know the problem is still there; so for example, if I decide to go treat myself a snack, I wouldn't enjoy the taste as much because the stress is still there, and the "time elapsed since you started" keeps increasing, which is annoying to think about when you ask yourself "how much did I accomplish in the last X hours".
Say you are 2 hours into the onset of some extreme frustration. In your experience, do the benefits of leaving for 20 minutes and coming back usually outweigh the costs of decreased efficiency from working in a bad mood?