You need to override the onStop method which is called whenever the application goes in the background. Beware you need to add this to all your activities or it will only stop for that particular activity.
@Override
public void onStop(){
super.onStop();
finish();
}