That's a feature in advancemame, I'm pretty sure... It's called "safe exit" or the like... (unless I'm confused). You can disable it, but I don't have the answer off the top of my head...
confirm which mame you are using and peruse the .rc file and if you are still stuck lemme konw..
rampy