stop method
Stops the scheduler, releases lock if held, and closes lock's and stateStore's own connections (e.g. RedisBeatLock/ RedisBeatStateStore sockets) — callers still own and must close app separately.
Implementation
Future<void> stop() async {
_running = false;
_timer?.cancel();
_timer = null;
if (_isLeader) {
_isLeader = false;
try {
await lock.release(id);
} catch (_) {
// Best-effort — the TTL will expire it regardless.
}
}
await lock.close();
await stateStore.close();
if (_stopSignal != null && !_stopSignal!.isCompleted) {
_stopSignal!.complete();
}
}