Also at the bottom of your retroarch.cfg file add:
input_enable_hotkey_btn = 6
input_exit_emulator_btn = 7
Replace 6 and 7 with numbers representing the buttons on your controller you want to hit that will exit a ROM you’re playing. On my controller 6 and 7 represent the Select and Start buttons.