Ofc.
You can configure a joystick key to exit on lot of emulators, inside the emulator configuration itself.
But somes emulators don't have this feature, so there are scripts for that, all scripts works with esc key. So the better way is use an application like joy2key or Xpadder, to bind a key (or a key combinaison) to the esc key.