close method
Close this Gateway instance, disconnecting all shards and closing the event streams.
Implementation
Future<void> close() async {
_closing = true;
// Make sure we don't start any shards after we have closed.
for (final timer in _startTimers) {
timer.cancel();
}
await Future.wait(shards.map((shard) => shard.close()));
_messagesController.close();
}