docs: protected boolean doShutdown() {
          if (state == State.NOT_RUNNING) {
              LOGGER.debug("Engine already shut down.");
              return true;
          }
          LOGGER.debug("Shutting down engine...");
          final Lock lock = this.lock.writeLock();
          try {
              lock.lock();
              state = State.STOPPING;
  
              if (!repositories.isEmpty()) {
                  // Now go through all of the repositories and request they all be shutdown ...
                  Queue<Future<Boolean>> repoFutures = new LinkedList<Future<Boolean>>();
                  Queue<String> repoNames = new LinkedList<String>();
                  for (JcrRepository repository : repositories.values()) {
                      if (repository != null) {
                          repoNames.add(repository.getName());
                          repoFutures.add(repository.shutdown());
                      }
                  }
  
                  // Now block while each is shutdown ...
                  while (repoFutures.peek() != null) {
                      String repoName = repoNames.poll();
                      try {
                          // Get the results from the future (this will return only when the shutdown has completed) ...
                          repoFutures.poll().get();
  
                          // We've successfully shut down, so remove it from the map ...
                          repositories.remove(repoName);
                      } catch (ExecutionException | InterruptedException e) {
                          Logger.getLogger(getClass()).error(e, JcrI18n.failedToShutdownDeployedRepository, repoName);
                      }
                  }
              }
  
              if (repositories.isEmpty()) {
                  // All repositories were properly shutdown, so now stop the service for starting and shutting down the repos ...
                  repositoryStarterService.shutdown();
                  repositoryStarterService = null;
  
                  // Do not clear the set of repositories, so that restarting will work just fine ...
                  this.state = State.NOT_RUNNING;
              } else {
                  // Could not shut down all repositories, so keep running ..
                  this.state = State.RUNNING;
              }
          } catch (RuntimeException e) {
              this.state = State.RUNNING;
              throw e;
          } finally {
              lock.unlock();
          }
          return this.state != State.RUNNING;
      }