In dealing with this type of players in term of your emotions, it's easier said than done but you just have to learn to have no stress, or handle stress properly from this situation. Have no hatred/spite toward other players like this. It's silly to expect changes of yourself immediately when it involves personalities, belief, etc.
In dealing with this type of players in-game by consoling/calming them down, there are different ways for different people and situations. As usual, resenting others isn't good. In this one, it's possible the player left out of embarrassment/pride after typing and dying. Or probably just got more angry/stressed and decided to do that.
As some players who afk like this are fragile/sensitive/defensive, it's important that your team let them know mistakes happened, and that your team does not insult/hate/whatever toward the person who'd afk. These situations usually end well, but the "afk'er" doesn't have nice teammates as well
If the person who would afk does well in performance, have a large pride, and rages at their teammates that actually did not perform well, I have no clue on what to do about it.