I use Stella for my Atari 2600 emu. I wanted to map ESC to close the emulator and there is no way to do this within the emulator itslef, so I setup Mala to do it. Here's how. Go to Other Emu Config > (select your emu) > Options tab > at the bottom check "Use Hotkeys" > Click Edit Hotkeys > Click the Add Button > Give it a name (like exit or shutdown) > For Type choose "Close" from the dropdown > Type the key you want to use in the source box (I pressed ESC) > Click OK and you're done.
Hopefully I understood your problem correctly. This hotkey essentially just kills the program, which is what you want. If so that should do it for you.
Good luck!