code: private int stop(final String[] args) throws IOException {
      setWorkingDir(args);
      final Path statusFile = getStatusPath();
      int exitStatus = 1;
  
      // determine the current state of the node
      readStatus(false, statusFile);
      if (this.status != null) {
        // upon reading the status file, request the Cache Server to shutdown
        // if it has not already...
        if (this.status.state != Status.SHUTDOWN) {
          // copy server PID and not use own PID; see bug #39707
          this.status = Status.create(this.baseName, Status.SHUTDOWN_PENDING,
              this.status.pid, statusFile);
          this.status.write();
        }
  
        // poll the Cache Server for a response to our shutdown request
        // (passes through if the Cache Server has already shutdown)
        pollCacheServerForShutdown(statusFile);
  
        // after polling, determine the status of the Cache Server one last time
        // and determine how to exit...
        if (this.status.state == Status.SHUTDOWN) {
          System.out.println(MessageFormat.format(LAUNCHER_STOPPED,
              this.baseName, getHostNameAndDir()));
          Status.delete(statusFile);
          exitStatus = 0;
        } else {
          System.out.println(MessageFormat.format(LAUNCHER_TIMEOUT_WAITING_FOR_SHUTDOWN,
              this.baseName, this.hostName, this.status));
        }
      } else if (Files.exists(statusFile)) {
        throw new IllegalStateException(MessageFormat.format(
            LAUNCHER_NO_AVAILABLE_STATUS, this.statusName));
      } else {
        System.out.println(MessageFormat.format(LAUNCHER_NO_STATUS_FILE,
            this.workingDir, this.hostName));
      }
      return exitStatus;
    }
docs: Stops a node (which is running in a different VM) by setting its status to
  {@link Status#SHUTDOWN_PENDING}. Waits for the node to actually shut down
  and returns the exit status (0 is for success else failure).