/** {@inheritDoc} */
  @Override
  public void close() throws IOException {
    if (closeGuard.compareAndSet(false, true)) {
      if (rmtClient == null) return;

      rmtClient.close(false);

      if (clientLog.isLogEnabled()) clientLog.close();

      if (factory instanceof LifecycleAware) ((LifecycleAware) factory).stop();

      // Reset initialized resources.
      rmtClient = null;
    }
  }