close method
Close cleanly: cancel the timer, stop listening, close events, and free the engine.
Safe to call after the transport has already closed on its own: that only ends events and tells the engine it is disconnected, since the engine's model survives a dead link on purpose so a reconnect can resume from it. This is what actually releases the native handle.
Implementation
Future<void> close() async {
_closed = true;
_timer?.cancel();
await _sub?.cancel();
await _events.close();
client.close();
}