Quoting from this question:
Android's design does not favor exiting an application by choice, but
rather manages it by the OS. You can bring up the Home application by
its corresponding Intent:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);
Note that his will not kill your app process, but rather put your activity on the background.
As for when to trigger this code, you should override the onBackPressed()
method for your current activity.