code: func (b *Backend) Close() error {
  	log.Info("gateway/mqtt: closing backend")
  
  	log.WithField("topic", b.eventTopic).Info("gateway/mqtt: unsubscribing from event topic")
  	if token := b.conn.Unsubscribe(b.eventTopic); token.Wait() && token.Error() != nil {
  		return fmt.Errorf("gateway/mqtt: unsubscribe from %s error: %s", b.eventTopic, token.Error())
  	}
  
  	log.Info("backend/gateway: handling last messages")
  	b.wg.Wait()
  	close(b.rxPacketChan)
  	close(b.statsPacketChan)
  	close(b.downlinkTXAckChan)
  	return nil
  }
docs: // Close closes the backend.
  // Note that this closes the backend one-way (gateway to backend).
  // This makes it possible to perform a graceful shutdown (e.g. when there are
  // still packets to send back to the gateway).