protected void implCloseSelectableChannel() throws IOException {
    synchronized (stateLock) {
      if (state != ST_KILLED) nd.preClose(fd);
      ResourceManager.afterUdpClose();

      // if member of mulitcast group then invalidate all keys
      if (registry != null) registry.invalidateAll();

      long th;
      if ((th = readerThread) != 0) NativeThread.signal(th);
      if ((th = writerThread) != 0) NativeThread.signal(th);
      if (!isRegistered()) kill();
    }
  }