I'm new to programming and have been using this site for a while now but everything I've had to ask has been answered somewhere but I couldn't find an answer to this:

I am programming a game for the Apple AppStore using Xcode and test it on the iOS Simulator. When I "Build and Run the current Scheme" (the play button on Xcode), I can test out my game, and when I am done I can hit the "Stop the running scheme or application" (the stop button on Xcode), and of course it ends my game.

However, on the iOS Simulator, an icon for my game appears on the main screen along with apple programs such as "safari". When I click this, it enters my game and I can play it fine. However when I click the "Home button" or the "lock button" and re-enter my game, the game is continuing from where I left off; I want the game to end so when I re-enter my game it goes back to its original state.

I was wondering if anyone had a solution to this problem? Thank you in advance for your time and help!