All your controller buttons and the hotkeys should already be in the controller file here:
/opt/retropie/configs/all/retroarch-joypads/{yourcontroller.cfg}
What are you trying to override by adding them here? (I dont think you can get controller #2 to exit the emulator, I think that has to be controller #1).
RetroPie help guides --> My YouTube RetroPie Channel
Please read this before asking for help --> How to get help