Great question, Oldandrolling!
This typically happens when I can’t stay on someone’s wheel (ie. keep up). My ego takes control of my thoughts and makes a mess of them, leaving me unable to focus/ride. I continue riding and try to turn my focus toward something else, leaving the frustration to fizzle. Whenever possible, I turn it into a skills ride, popping off rocks and working in cornering speed.
Similar to the kayaker’s slogan SKleen shared above, a shit day on the bike is better than any day on the couch.