public void close() {
    if (closed.compareAndSet(false, true)) {
      try {
        channelManager.close();

        // FIXME shouldn't close if not allowed
        config.executorService().shutdown();

        if (allowStopNettyTimer) nettyTimer.stop();

      } catch (Throwable t) {
        LOGGER.warn("Unexpected error on close", t);
      }
    }
  }