a lot of it can be how you are sitting and holding the guitar. sometimes if I do a bad take or three, I'll realize I'm hunched over and super tensed and not even holding the guitar like I normally do. then I sit back in the chair with a who-gives-a-shit attitude then bam, that's usually the one.
however, another item that is tricky is...you THINK you just flubbed it, but in actuality you nailed it. I often find my best solos were ones that I thought I goofed up. Every time I've been in a "real" studio with someone else recording, they catch it - the solo I was going to toss, they say keep.
I've adopted a total Zen to solos anymore....I say screw what you are trying to capture in terms of "this is how the solo should be played." free your mind from that. if something jumps into your solo that wasn't supposed to be there....it was supposed to be there. It's what your mind and body wanted to play. I've kept solos with bad notes, off-key phrases, etc. simply because the vibe was on. But I'm just recording stupid songs for my own pleasure, not to please someone else.