Oop! Sorry, I somehow had it in my mind that I responded to you. I must be going senile.
You can remap the exit button in Mame with a press of a button or a combination of buttons. Just while in game, hit tab on the keyboard, goto the "Input (general)" option, then "User Interface" then you should see the quit is mapped to the esc button. (I think they call quit "UI Cancel"). You can remap this to be whatever button you want from the encoder. If you push more than one at once, it will know to quit only when you push both buttons. I have mine set to quit when I push both "Coin" and "start" at the same time.
I don't know if you are using other emulators as well, but there is a method you can use if you come across a pesky emulator that won't let you remap the escape button. Just download Joy2Key. It is a small program that runs in the background and translates joystick presses into keyboard inputs. You can set a button to equal ESC or whatever button is needed to exit your emulator, then leave the program to start up with your computer. You can also use Xpadder, and it has some awesome advanced features, but it does cost like $10. Joy2Key is free.
Hope that answer is what you are looking for. Let me know if you need anything else. Again, sorry for the delayed response.