code: func (s *Stream) Close() error {
  	closeStream := false
  	s.stateLock.Lock()
  	switch s.state {
  	// Opened means we need to signal a close
  	case streamSYNSent:
  		fallthrough
  	case streamSYNReceived:
  		fallthrough
  	case streamEstablished:
  		s.state = streamLocalClose
  		goto SEND_CLOSE
  
  	case streamLocalClose:
  	case streamRemoteClose:
  		s.state = streamClosed
  		closeStream = true
  		goto SEND_CLOSE
  
  	case streamClosed:
  	case streamReset:
  	default:
  		panic("unhandled state")
  	}
  	s.stateLock.Unlock()
  	return nil
  SEND_CLOSE:
  	s.stateLock.Unlock()
  	s.sendClose()
  	s.notifyWaiting()
  	if closeStream {
  		s.session.closeStream(s.id)
  	}
  	return nil
  }
docs: // Close is used to close the stream