What emulator or emulators are you having issues with? Most should close fine just using the controller/keyboard automation in LB/BB and not needing AHK or even JoyToKey? I think I only have 1 or 2 I use an AHK script for.
I would caution to not use the Process, Close command. It can cause save state issues with emulators that might save a game state on close.
Use this instead.
$Esc::
{
WinClose, ahk_exe {{{StartupEXE}}}
}
To answer your question though you can use something like below. The -1 in SetKeyDelay means no delay. I am no expert just passing along info. Also this thread is good to look over. Joy7 is the select button and Joy8 is start on one of my controllers. So you would just change those numbers to what it is on an Xbox controller.
Joy7::
If GetKeyState("Joy8")
{
SetKeyDelay, -1, 110
WinClose, ahk_exe {{{StartupEXE}}}
}
Return