title: How to exit from Android App even if current Activity is not Main Activity
body: <p>I have this activity flow</p>
  
  <p>HomeActivity > Activity1 > Activity2 > Activity3 > HomeActivity</p>
  
  <p>I switch back directly from Activity3 to HomeActivity  by pressing cancel button on Activity3.</p>
  
  <p>but when I press back button on HomeActivity  I want to exit from the app, however it takes me back to Activity3... how to exit the app??? this is my code
  on Home activity:</p>
  
  <pre><code>@Override
      public void onBackPressed() {
              finish();
              System.exit(1);
          }  
  </code></pre>
  
  <p>if I press back button when App is just started on HomeActivity it works normally, closing the app...</p>
  
  <p>How to make it work when I navigate through all these other activities?</p>