Welcome aboard, Benny.
Assuming you are referring to MAME, press escape on the keyboard to exit the game (default setting) and return to the front end where you selected the current game.
If you want to change the MAME button/keystroke for exit, press tab to bring up the menu and change the setting in the "Input (general)" -- "User Interface" menu
* Highlight "UI Cancel"
* Press enter
* Press the button/keystroke you want to use to exit
Scott