How do you detect that you've left this App?

How do you detect that you’ve left this App? In other words let’s say you’ve started running a program made with Codea but you then double click the home button to go to your multitask bar?

Is there away to detect that you’ve gone to your multitask bar?