code: private static void sequence() {
          synchronized (lock) {
              /* Guard against the possibility of a daemon thread invoking exit
               * after DestroyJavaVM initiates the shutdown sequence
               */
              if (state != HOOKS) return;
          }
          runHooks();
          boolean rfoe;
          synchronized (lock) {
              state = FINALIZERS;
              rfoe = runFinalizersOnExit;
          }
          if (rfoe) runAllFinalizers();
      }
docs: /* The actual shutdown sequence is defined here.
  
  If it weren't for runFinalizersOnExit, this would be simple -- we'd just
  run the hooks and then halt.  Instead we need to keep track of whether
  we're running hooks or finalizers.  In the latter case a finalizer could
  invoke exit(1) to cause immediate termination, while in the former case
  any further invocations of exit(n), for any n, simply stall.  Note that
  if on-exit finalizers are enabled they're run iff the shutdown is
  initiated by an exit(0); they're never run on exit(n) for n != 0 or in
  response to SIGINT, SIGTERM, etc.