title: How can I close my software in a safe way?
body: <p>Up to now I used my application as a stand alone product. So, when user pressed "Stop" button I called <code>System.exit(0);</code> and it was fine.</p>
  
  <p>Now my application will be called (in a programmatic way) from another program. So, I afraid that <code>System.exit(0);</code> will kill not only my process but also the external software which started my program.</p>
  
  <p>So, what is the correct way to shutdown my application if a corresponding request from an external software is received? My application is an GUI application. So, I want to close the window but I also want to close all processes performed by my program.</p>
  
  <p><strong>ADDED:</strong></p>
  
  <p>To be more specific, I want to close all threads started by my program. My program does not start any OS process or any other program.</p>