I created a menu and put an exit button in it. Now when I click on it, it behaves like a back button and closes the activity.
I want the application to be closed completely by this button. I typed this code at the end of my program:
finish();
System.exit(0);