If this is a global solution than should I put in the code that all emu's launch this way? 
Possibly. I haven't used Mala to launch mame.exe for a long time since I use the batch file method of combining emulators into one game list. Just for testing, I changed my executable in Mala from mame.cmd to mame.exe just to see if Mala lost focus with my build. Indeed it did lose focus after exiting a mame game every time.
I went back to using mame.cmd with the contents of "start /B mame.exe" and no longer had the loss of focus problem within Mala. It is very repeatable so if you wanted to compile a test Mala.exe which consists of launching mame.exe in a similar fashion then I can test and tell you if the focus issue goes away. Just let me know.
I'm sure it would be great if the need to use scripts to simulate a mouse click could be eliminated.