Q:

How to Manage Player Frustration and Disengagement

Many RPGs have random elements, such as dice rolling, which can determine success or failure of an action. In some of these games, failure basically means the player character does nothing or contributes nothing on that round.
For example, in D&D 4e, there are a great many encounter powers with cool effects when they hit and no effect at all if they miss. If the player misses, they may as well have said "I do nothing" on their turn. A player's entire contribution to the game is predicated on the dice "allowing" them to contribute.
However, the issue I want to discuss in this question isn't the mechanics of the game that leads to this "fail and do nothing" event, but how the players deal with it. Sometimes, players will roll a failure and will just walk away from the table. Sometimes it can become difficult to engage with the players who are failing roll-based checks because they are disengaging with the game.
(example: Player declares attack, rolls die, sighs in frustration and says "I miss" and turns away from the table or picks up their phone or whatever. All before anyone else can get a word in edgewise.)
In a previous question, edgerunner's answer to dealing with bad rolls themselves was to make an awesome story out of failure. I really like that answer and I'm going to pitch it to my group, but I realized it would still be difficult to overcome the psychological disengagement that happens with bad rolls. The players stop trying to do anything, role-play or otherwise, when they're overcome with dice frustration. How can I help them get back into the game and help them engage in the failure role-play?

This question is not asking how to avoid bad rolls. If you have that kind of answer, please post it to Balancing players' rolls, not characters instead.

A:

If your players are easily frustrated by a few bad dice rolls, that's a problem with your game in general. Bad dice rolls happen. And they will happen a lot. If the laws of the universe don't change in the near future, I would even dare to say they will happen with the same frequency that applies to good dice rolls. 
After all, your players don't get frustrated rolling too good, do they? Did they ever leave the table because the rolled 3 criticals in a row totally dominating the encounter? So the real problem probably is, that their only action and therefore their only fun producing aspect of the game is winning the dice roll. That is fine for a board game, but not exactly the goal of roleplaying games. 
You can do a lot more in a turn of combat than stand there and hit the enemy. You can move to flank the enemy. You can taunt him (just in character, without any rules involved). You can be creative. You can have a lot of fun with failures. My most memorable moment in roleplaying was when my ninja character failed so miserably sneaking out of a bar that she ended up on the doorsteps with a broken ankle and screaming. Sure, that was a failure, the worst possible combination of dice I ever saw, but it was still fun and a happy memory meeting the people of this group even ten years later. But you need to encourage it and you need to allow it, even if (especially if!) it's not in the rules.
Example: Playing a specialized magic user, our party once met a monster that was completely immune to any of my magic. I could have taken the second (or third) row in combat shooting ordinary arrows at it. I would probably have missed 20 times in a row. It would have been incredibly boring. After 10 misses I would probably have left the table, too. Life is too short to be bored. Instead my character switched into light armour (no proficiency, but who cares), got a dark cape and a dagger and sneaked behind the monster. He failed the sneak roll, he was unable to cast magic due to the armor and he really sucked at hitting it with the dagger. BUT: the GM decided it would turn to me and leave it's back turned to the warrior leaving it open to his attacks, because even the dumbest monster knows that those sneaky dark dagger people hurt the most. I failed every single roll that combat and still contributed and had fun. 
Remember, as a GM you need to encourage and allow it. No rule ever said that monsters need to turn to the sneaky git with a dagger. That was good GMing. We had fun. Much more fun than any fireball-damage-dice-rolling-spell could have brought. Build your encounters so that the players feel they can be creative. And allow them to be creative. If the players are creative, then no dice roll is needed to "allow" them to contribute. Contribution is measured in fun, not damage points.
--- Edit: ---
The first part was about what can be changed in the gaming group and playstyle to make failed rolls less frustrating. A commenter remarked that sometimes it has nothing to do with the game or group and that's absolutely right:
Some players simpy cannot lose. They can't. If they lose, they get frustrated. But losing is part of any game. I guess we all know people who are like that. It's also never them. It's the noob team. Or the dice. Or whatever. If the game was lost, somebody must have been a bad player. That you can play a game, be good at it, have fun and still lose doesn't fit in their world view. For them, it's about winning, not about having fun playing. If this is the case with your player, there is little that you can do to change that. For him to be the winner every time, the rest would have to lose. And you can't have that in a group. That's not fair to the others. 
Some players are just bad at statistics. They don't have bad luck. They only feel like they had bad luck because they don't know better. Some people need a 18 to hit on a d20 and think missing 3 times in a row is incredibly bad luck. It's not. To the contrary, it would have been pretty lucky to hit just once in three tries. Make sure the players know at least basic statistics and can convert your systems dice rolling to percentages, so they have a number they can grasp. 
Some people are building their characters with damage dealing as a priority. They can dish out huge amounts. Many dice. Large numbers. But most systems are quite balanced, so to achieve this, they sacrificed something. Most likely their chance to hit. So they sit there round after round waiting for their one moment of glory where they land a lucky hit to show off their uber damage. That's a decision. They could as well have build a character that attacks three times a round for little damage and in a good system it would have the same end result. As long as they look only at one number (damage) and not at the full picture (damage * chance to hit), they will frustrate themselves every time. Make sure they know that this is their own decision, because they can only change this situation themselves.

A:

A few ideas that have worked for some groups of mine in the past:

In systems that care about tactical decisions (Legend, 3.X, 4e), see if there's other things that the player could be doing in their turn, like making useful skill checks, enabling tactical positioning, or even trying another gambit. If a player seems consistently frustrated with binary "yes/no" dice rolls, encourage them to seek concepts and/or mechanical builds that have more options per round available to them.
Show off some awesome failure yourself. Did your NPC whiff his mighty charge? Maybe the orc spins crazily, trying desperately to control his swinging axe. Describe the dripping spelltaint that runs through the fingers of an NPC spellcaster whose magic has been foiled, or hammer home the desperation of a "reliable" Hedge guide (Changeling: the Lost) who can't seem to succeed at his navigation rolls. Don't ham it up (unless your table likes that kind of thing!) but doing this sort of thing can serve as an olive branch and a demonstration that roleplaying failure doesn't mean you've done something wrong.
Offer roleplaying XP or minor mechanical rewards. In my opinion this option can be sorta like inscribing what you want on a brick and beating your players with it, but sometimes it works and it might get your players to have fun in these situations.
Try to work with your players when describing these sorts of events. If a player makes a tough, no-nonsense warrior of Summer, then maybe you shouldn't describe the failed roll as slapstick comedy; likewise, if you're playing Toon you probably should represent it as slapstick. Players will tell you what kinds of themes and moods they want to deal with when they make and personify their characters - working with those themes and moods can help take the sting out of the failed roll.
Make failure less likely by teaching your players to optimize. Feeling in control of their own fate can help ease back the feeling that the dice have more agency than the player does. Make sure you discuss with your group the level of optimization you want to fall under and approach this with maturity and respect - some groups are just fine with having the PCs construct their own fortress-demiplanes, but if yours isn't you should decide where the line rests as a group, not as a GM dictating it to the players.
Talking is a free action in almost all systems. Encourage players to plan tactically during combat; that way, even if the player who failed his roll doesn't feel like roleplaying they can still meaningfully contribute to the group as a whole.

Some additional ideas:

Some systems already have rules in place for "circumstance" bonuses and penalties that affect a roll based on factors like advantageous positioning, experience with the subject in question, slick ice, or poor library catalogs. Consider making use of (or inventing!) such rules in your game - it'll help alleviate some of the failed roll problems, but it'll also help your players feel creative.
White Wolf's Storytelling systems include a kind of "roll" (challenge, really) known as "Extended and Contested", which I've used to great effect in other systems with a bit of tweaking. Essentially, an Extended and Contested roll involves a conflict between two parties that takes some amount of time beyond a combat round (like a foot chase, a hot dog eating contest, a climbing competition, etc). Each party involved makes rolls as appropriate - maybe they're pinning down the vampire while one PC drives the stake, maybe it's a case of Drive vs. Athletics while a sprinting man tries to catch a taxi cab - and compare results. In Storyteller systems, there's usually some kind of threshold for total successes needed for one party to claim victory, but there's no reason yours needs to work that way. Extended and Contested rolls tend to be a lot better for non-combat scenes than they are for combat ones, and they have the advantage that a single roll doesn't necessarily put you out of the running. Chasing a dangerous necromancer, a paladin in Legend might roll Athletics (against the necromancer's athletics) only to find that the necromancer edged him out and is staying ahead. The paladin trips the necromancer up by cutting a clothesline that tangles into him (a successful engineering against the necromancer's failed acrobatics, maybe), then manage to grab the wily fiend and subdue him (opposed grapple checks). The downside, of course, is that it does involve more dice rolling at the table, which can sometimes take up time. I highly encourage the use of this system with the circumstance bonus/penalty system mentioned above.

A:

First, realize that randomness is part of some of these games.  The best approach may be to simply accept this fact.  If the fact that randomness is a factor bothers the player, then perhaps this game is not the right one for them.  Games have a spectrum of how much is luck and how much is random.  Games like Go or chess have essentially no chance involved.  But other games like Magic: The Gathering, Poker and many role playing games involve Luck alongside skill, and that is just a factor of the game.  
Since randomness is part of some of these games, consider games that involve close to no chance if the random element really bothers some players.  I haven't tried it, but I understand Amber involves no luck.  Fate involves substantially less dice rolling.
The middle ground is to help them to see and take advantage of the secondary tactical effects.  Perhaps Bob the Barbarian's attack missed and did nothing.  He is still tying up that particular threat so that the threat isn't charging at Wally the Wizard.  He is also distracting that target so Roger the Rogue can set up a backstab.  This is similar to how you might need to line up your Rook in the right place so your Knight can capture the queen.  In a more modern setting, Gary the Gunsman might have missed hitting the mook, but the mook might be ducking behind cover instead of firing the next round because of Gary's shot.
You can also help them find techniques that minimize their own rolls.  A character built around buffing the teammates will have fewer rolls than one built around slicing the enemy.  And, especially when talking about spells, many of them have only a reduced effect if the other party resists rather than no effect.  So the turn isn't "wasted".  Of course, there is often a trade off.  Many techniques are high-risk, high-reward.  They can do spectacular things, or nothing at all, or even make things worse (see Botch in shadowrun, etc.).  Many of the techniques that have less risk also come with less payoff. 

