/** Shut down the HTTP server and all its workers, and close the listener socket. */
  public void stopServer() {
    shouldRun = false;
    try {
      listener.close();
    } catch (IOException ex) {
      // Don't care
    }
    while (true) {
      synchronized (allWorkers) {
        if (allWorkers.isEmpty()) {
          break;
        }
        for (Worker w : allWorkers) {
          w.stopSocket();
          w.interrupt();
        }
      }
    }

    try {
      listener.close();
    } catch (IOException ex) {
      ex.printStackTrace();
    }
  }