I'm not sure which version of Android has become available, but at least Jelly Bean has a developer option that makes this very easy. In the Settings → Developer Options section , go to the Services section and enable the Do not perform actions option.
Then, when you exit the application (using the "Back" button or the "Home" button), the OS will destroy this activity of the application, and not just pause it and put it in the background. However, be sure to cancel this setting when you are done testing.
source share