protected void cancel( NioEndpoint p ) throws IOException
        {
            SelectionKey key = endpointKeys.remove(p);
            if( key == null ) {
                //log.log( Level.FINE, "Endpoint already closed:{0}.", p );
                return;  // already closed it
            }                
            log.log( Level.FINE, "Endpoint keys size:{0}", endpointKeys.size() );

            log.log( Level.FINE, "Closing endpoint:{0}.", p );
            SocketChannel c = (SocketChannel)key.channel();

            // Note: key.cancel() is specifically thread safe.  One of
            //       the few things one can do with a key from another
            //       thread.
            key.cancel();
            c.close();
            removeEndpoint( p, c );
        }
Because we want to keep the keys to ourselves, we'll do
 the endpoint -&gt; key mapping internally.
jme3-networking/src/main/java/com/jme3/network/kernel/tcp/SelectorKernel.java