This is a well-known "issue" with the M92. There are at least 2 relatively easy counters for such "snatch the top of the gun" tricks.
First, and perhaps easiest, is to remove the "shelf" from the takedown lever (the protruding part that you press on to rotate the lever). A few minutes with a Dremel or a file will solve the problem, and render your 92 immune to such snatches. Mine is so modified, & people who thought they would "show me something I didn't know about the 92" got a rude surprise instead (all in training, of course).
I'm also partial to Massad Ayoob's comments re: this "problem" with the Beretta 92 (I'm paraphrasing): If you can guarantee that every punk I ever face over the Beretta will try this snatch, I'll gladly carry the 92 for the rest of my life, and shoot the SOB with my backup gun while he's holding the top half of the 92 & laughing at me.
Of course, you held still for your buddy's attempted grab, too, which greatly improves the odds of it's success. In a real-life situation, you likely would not do so; it's much harder to hit the release button and the takedown lever simultaneously when the gun is in motion. Also, you should be able to put at least one bullet into the attacker, which probably would slow him up, if not completely change his mind about continuing the attack.
Just my 2 cents.
David