code: func (e *endpoint) cleanupLocked() {
  	// Close all endpoints that might have been accepted by TCP but not by
  	// the client.
  	if e.acceptedChan != nil {
  		close(e.acceptedChan)
  		for n := range e.acceptedChan {
  			n.mu.Lock()
  			n.resetConnectionLocked(tcpip.ErrConnectionAborted)
  			n.mu.Unlock()
  			n.Close()
  		}
  		e.acceptedChan = nil
  	}
  	e.workerCleanup = false
  
  	if e.isRegistered {
  		e.stack.UnregisterTransportEndpoint(e.boundNICID, e.effectiveNetProtos, ProtocolNumber, e.id, e)
  		e.isRegistered = false
  	}
  
  	if e.isPortReserved {
  		e.stack.ReleasePort(e.effectiveNetProtos, ProtocolNumber, e.id.LocalAddress, e.id.LocalPort)
  		e.isPortReserved = false
  	}
  
  	e.route.Release()
  	tcpip.DeleteDanglingEndpoint(e)
  }
docs: // cleanupLocked frees all resources associated with the endpoint. It is called
  // after Close() is called and the worker goroutine (if any) is done with its
  // work.