code: @CLIMethod(name="shutdown")
      @RequirePOST
      public void doExit( StaplerRequest req, StaplerResponse rsp ) throws IOException {
          checkPermission(ADMINISTER);
          if (rsp!=null) {
              rsp.setStatus(HttpServletResponse.SC_OK);
              rsp.setContentType("text/plain");
              try (PrintWriter w = rsp.getWriter()) {
                  w.println("Shutting down");
              }
          }
  
          new Thread("exit thread") {
              @Override
              public void run() {
                  try {
                      ACL.impersonate(ACL.SYSTEM);
                      LOGGER.info(String.format("Shutting down VM as requested by %s from %s",
                              getAuthentication().getName(), req != null ? req.getRemoteAddr() : "???"));
  
                      cleanUp();
                      System.exit(0);
                  } catch (Exception e) {
                      LOGGER.log(Level.WARNING, "Failed to shut down Jenkins", e);
                  }
              }
          }.start();
      }
docs: Shutdown the system.
  @since 1.161