A hint in case someone else is getting the same problem. If you use the Picade X HAT, and upgrade Retropie to the latest 4.4.1 version, then pressing the “Coin” button kills mame (and possibly other emulators).
What happened is this: They enabled “screen recording” in 4.4.1. The default toggle button to enable/disable recording is “o”. By bad luck, this is also the “Select” button on the X HAT, which maps to “Coin” in mame.
So, when you hit the coin button the screen recording starts, and immediately crashes on the Raspberry Pi. I don’t know why this got enabled in Retropie 4.4.1 if it just crashes.
To fix this the toggle button has to be remapped to something that does not exist, such as “q”. You have to ssh into Retropie, and then edit “/opt/retropie/configs/all/retroarch.cfg”. Look for the line with “input_movie_record_toggle”. Uncomment it, and change the “o” to e.g. “q”.