code: public static int exit(ApplicationContext context,
  			ExitCodeGenerator... exitCodeGenerators) {
  		Assert.notNull(context, "Context must not be null");
  		int exitCode = 0;
  		try {
  			try {
  				ExitCodeGenerators generators = new ExitCodeGenerators();
  				Collection<ExitCodeGenerator> beans = context
  						.getBeansOfType(ExitCodeGenerator.class).values();
  				generators.addAll(exitCodeGenerators);
  				generators.addAll(beans);
  				exitCode = generators.getExitCode();
  				if (exitCode != 0) {
  					context.publishEvent(new ExitCodeEvent(context, exitCode));
  				}
  			}
  			finally {
  				close(context);
  			}
  		}
  		catch (Exception ex) {
  			ex.printStackTrace();
  			exitCode = (exitCode != 0) ? exitCode : 1;
  		}
  		return exitCode;
  	}
docs: Static helper that can be used to exit a {@link SpringApplication} and obtain a
  code indicating success (0) or otherwise. Does not throw exceptions but should
  print stack traces of any encountered. Applies the specified
  {@link ExitCodeGenerator} in addition to any Spring beans that implement
  {@link ExitCodeGenerator}. In the case of multiple exit codes the highest value
  will be used (or if all values are negative, the lowest value will be used)
  @param context the context to close if possible
  @param exitCodeGenerators exist code generators
  @return the outcome (0 if successful)