When the user hits the Home button the newer versions of iOS, you will get a calls to applicationWillEnterBackground/applicationDidEnterBackground which indicate that you're going and have entered the background stage. You have a finite amount of time (about 5 seconds) to finish whatever you are doing (save state, kill connections, whatever) and then return to allow the OS to go on. If you don't do that, your application will be killed.
However, if you want to run something for a bit longer you can use beginBackgroundTaskWithExpirationHandler to continue a job in the background for a bit longer and it's probably possible to change these calls with the Expiration Handler to continue on infinitely. However, that is not really what this is designed for and you will end up depleting the battery of the iOS device pretty quickly..
Look these functions up on the developer reference for more information about them..