Sorry to bump an old post. How would that script work with the new Tankstick that uses mouse button 3 to exit games?
Red button is mapped - Per Arcade-x - This new version has a special added function on the top right corner of your Tankstick: red LED button mapped to Mouse M3 (SEE IMAGE) which can be configured as EXIT in MAME or your emulator.