I don't know if it's still an issue, but I had a similar problem and found the solution by using a free program called "Joy Cursor" (I'm sure this is similar to JoyToKey). Actually, I'm not sure if that's the name of the program, but I do know a google search for "joycur" will yield results. The Joy Cursor program allows you to map keys and key combinations to button presses on the gamepad. I'm using a DualShock 2 Controller via a SmartJoy USB adapter, which works beautifully in MAMEwah. I used Joy Cusror to map the "Alt-F4" combination to the R3 button (pressing in the right analog stick) which is inaccessible unless the "Analog" feature is activated on the gamepad. This requires you to press the "Analog" button before hitting R3, so no accidental exits. Once the R3 button is pressed, the emulator shutsdown and I'm instantly returned to MAMEwah. My system is still in the early development stages, so I currently only have six emulators, but I exit them all like this and have not yet had any problems.