Please forgive me, it did not happen while playing D&D 5E or D&D period, but it's the only genuinely galling experience I've had with a GM (most are just kind of...mediocre), and I think it's a funny story, too.
I did not walk away, but the most annoying thing a GM ever did to me was at a convention, Origins I think. He was running CthulhuTech, but in such a way as to phase out the giant robots and downplay the tech. I don't know why he wasn't just running CoC but WHATEVER. I got a pre-generated character and as I quickly picked up on the basics of the game (first and last time I played it) I realized that all I had was a mediocre (and that's putting it generously) pistol, and just enough of a smidgen of pyrokinesis, specifically enough talent to like, ignite a spark to set blaze to flammable objects, but not straight up hurl a fireball at someone or will them to spontaneously combust. About half of the pregens were normal human beings and the other half were some kind of gengineered Lovecraft-monster humanoids that were wildly more powerful than the humans.
Anyway, so, much boring investigation ensued (it was years ago, I wasn't paying that much attention even at the time, and I remember nothing about the setting) and eventually the quarry we were hunting lead us to a gas station: they were inside the gas station, which the GM described as having abandoned gas pumps surrounded by tall, dry grass. Having done jack squat to contribute to the party this entire session, I tried to use my tiny little micro-pyrokinesis--which was my character's only power and the only thing that differentiated him or made him special, this being a character I'd picked BECAUSE I saw pyrokinesis on the sheet and wanted to burn stuff--to to ignite the dry grass, presumably setting fire to the pumps in the process (which might still be connected to a gasoline reservoir), and burning out the monsters from their lair.
The DM told me that I couldn't because, I 


you not, "dry grass isn't...really...that...flammable".
My character continued to be irrelevant for the rest of the adventure. He was not alone.
If I wasn't there representing my company and thus constrained to polite behavior, I think I would have walked. As it is, I had already been making notes during the session of everything the GM was doing wrong. It wasn't abuse, it was constructive criticism, but it was pretty damn harsh, tough love, heavier on the tough than the love. I handed the paper with my notes unsolicited to the GM as we left.
I ran into him later on that day when we were both in line for Subway. IT WAS SO AWKWARD. We each pretended the other wasn't there for like ten minutes in line lol.
Anyway, I'm really interested in the inverse of this topic: DMs, when have you found it necessary to fire a player from your table?
E: from page one:
"
Game where GM was trying to use game to out a player."
...like...as an IRL Russian Spy? I mean, I realize you're probably talking about someone's sexual orientation but I just...I literally cannot fathom...why any GM would feel the need to do that...ever.