code: public static void makeProcessExitOnUncaughtException(final Log log) {
      Thread.setDefaultUncaughtExceptionHandler(
        new Thread.UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(Thread t, Throwable e) {
            log.error("UNCAUGHT: Thread " + t.getName() +
              " got an uncaught exception", e);
            System.exit(1);
          }
        });
    }
docs: Sets an uncaught exception handler. This will make the process exit with
  exit code 1 if a thread exits due to an uncaught exception.