I'm pretty sure it's actually MAME that's not really quitting and mGalaxy is simply waiting for it to exit!
To test it, place the attached script (MAME.au3, just below) in mGalaxy>Data>Scripts.
This script will have the effect of "killing" MAME.
Then come back here to tell me if it worked!