private void cleanUp(boolean shutdown, String message) {
    try {
      sr.done();
    } catch (ShutdownException se) {
      // Nothing to do at this point, we're already shutting down
    }

    if (niagara.connection_server.NiagraServer.TIME_OPERATORS) {
      cpuTimer.stop();
      cpuTimer.print(getName() + "(shutdown: " + message + ")");
    }

    try {
      if (!shutdown) outputStream.endOfStream();
      else
        // REFACTOR
        outputStream.putCtrlMsg(ControlFlag.SHUTDOWN, message);
    } catch (java.lang.InterruptedException ie) {
      /* do nothing */
    } catch (ShutdownException se) {
      /* do nothing */
    }

    outputStream = null;
    sr = null;
    return;
  }