Hyundai Tucson Shuts off

I drive a 2006 Hyundai Tucson and lately it shuts off on its own, usually when I am idle. I can recreate the issue by driving 20 - 60 mph, then pressing the breaks pretty firmly (not abruptly), then taking my foot off the break but not pressing the accelerator. The car reacts by shutting off. No sputtering, just off; If I put it back in park and turn the key it starts again, no problem. What could this be?

Stalling problems that go along with braking tend to be associated with brake booster problems. Your case doesn’t completely make sense (at least to me) because a complete stall would come from a pretty large booster leak - and if you have one
that large it should show up under more than only the conditions you describe. But it is the first thing that comes to mind.

If you just sit at idle and press the brakes really firmly what happens? Anything? How about sitting at idle, press the brakes firmly and release? Does the engine stumble or shake at all when you do this?

When the car is moving, and you press the brakes, to what speed does the car slow when it stalls? The car has to be stopped for you to be able to put the transmission into park.