code: public void close() throws IOException {
      if (closed) {
        return;
      }
      closed = true;
  
      stopIn();
      stopOut();
  
      // socket streams and socket itself should be already closed with stopIn() and stopOut()
      // but because it is idempotent, let's be good citizens and close corresponding streams as well
      in.close();
      out.close();
  
      terminateExecutor(readExecutor, "read");
      terminateExecutor(orchestratorExecutor, "orchestrator");
  
      socket.close();
    }
docs: Closes communication socket gracefully