Yeah, I wouldn't hook up any kind of timer directly to the power of the cabinet.
I suspect there's plenty of little utility type apps that allow for timed shutdown of a cab.
Here's one, though it's a paid version
http://www.accuratesolution.net/solutions/automatically-turn-off.htmBut even that's not a great solution. It's just a time based solution. Ideally, I'd think you'd want to give physical "credits" for game play, a bit like an allowance, maybe? But that would require a coin door of some sort. I guess I think that would be best because it links the game play to a physical, tangible element.
Alternately, you might be able to come up with a glovepie or autohotkey script to convert one keypress into another, up to a limit.
So, say your P1 and P2 were mapped to the A and Z keys. Mame wouldn't react to those keys at all.
Now, you have an autohotkey script that basically says,
I've got X credits available.
If there's more than 0 Credits and I see an A or Z pressed (the actual coin buttons) kill the keypress and instead simulate a 5 or 6 (the keypress MAME expects to see).
If there's 0 credits left, just kill the keypress and be done.
Best would be to set the AHK script to only do that when MAME is the actual application with focus, I'd imagine.
I haven't done much AHK scripting, but from what I know about it, I suspect it could accomplish this.
I've actually had a similar thought about my cab with respect to my daughter. Having infinite credits available completely changes the tone of the old arcade experience, makes it more like a console.
Ok, done rambling.