code: func (e *endpoint) Close() {
  	e.mu.Lock()
  	e.shutdownFlags = tcpip.ShutdownRead | tcpip.ShutdownWrite
  	switch e.state {
  	case stateBound, stateConnected:
  		e.stack.UnregisterTransportEndpoint(e.regNICID, []tcpip.NetworkProtocolNumber{e.netProto}, e.transProto, e.id, e)
  	}
  
  	// Close the receive list and drain it.
  	e.rcvMu.Lock()
  	e.rcvClosed = true
  	e.rcvBufSize = 0
  	for !e.rcvList.Empty() {
  		p := e.rcvList.Front()
  		e.rcvList.Remove(p)
  	}
  	e.rcvMu.Unlock()
  
  	e.route.Release()
  
  	// Update the state.
  	e.state = stateClosed
  
  	e.mu.Unlock()
  
  	e.waiterQueue.Notify(waiter.EventHUp | waiter.EventErr | waiter.EventIn | waiter.EventOut)
  }
docs: // Close puts the endpoint in a closed state and frees all resources
  // associated with it.