@Override
  public void destroyConnection(final Connection connection) {
    if (connection == null) {
      return;
    }
    if (logger.isFinestEnabled()) {
      logger.finest("Destroying " + connection);
    }

    if (activeConnections.remove(connection)) {
      // this should not be needed; but some tests are using DroppingConnection which is not a
      // TcpIpConnection.
      if (connection instanceof TcpIpConnection) {
        ioThreadingModel.onConnectionRemoved((TcpIpConnection) connection);
      }
    }
    final Address endPoint = connection.getEndPoint();
    if (endPoint != null) {
      connectionsInProgress.remove(endPoint);
      connectionsMap.remove(endPoint, connection);
      fireConnectionRemovedEvent(connection, endPoint);
    }
    if (connection.isAlive()) {
      connection.close();
      closedCount.inc();
    }
  }