The browser object has that condition. Also I think the wall clock idea is better than letting the game run in the background. If you get the DateTime plugin you can extend the idea to getting money when the game is closed.
Anyways here's a simple example of an idle game:
Global number money=0
Global number moneyPerSec=10
Global number suspendTime=0
Every 1.0 seconds
--- add moneyPerSec to money
On suspend
--- set suspendTime to wallClockTime
On resume
--- add (wallClockTime-suspendTime)*moneyPerSec to money