title: Difference between ExitCodeGenerator and System.exit(0)
body: <p>I recently learned that the proper way to shut down a Spring Boot application is this:</p>
  
  <pre><code>public class Application {
  
      @Bean
      public ExitCodeGenerator exitCodeGenerator() {
          return new ExitCodeGenerator() {
              @Override
              public int getExitCode() {
                  return 0;
              }
          };
      }
  
      public static void main(String[] args) throws Exception {
          System.exit(SpringApplication.exit(SpringApplication.run(Application.class, args)));
      }
  }
  </code></pre>
  
  <p>This should return an exit code of 0, or whatever I configure it to return in the <code>getExitCode()</code> method. My question is - what is the difference between doing the approach above vs the one below:</p>
  
  <pre><code>public class Application {
  
      public static void main(String[] args) throws Exception {
          SpringApplication.run(Application.class, args);
          System.exit(0);
      }
  }
  </code></pre>
  
  <p>The application seems to be shut down in exactly the same way by both approaches, at least in the console. So what's the difference?</p>