shutdown method
Implementation
Future<void> shutdown() async {
if (_isShutdown) return;
if (_isShuttingDown) {
throw StateError('Shutdown already in progress');
}
_isShuttingDown = true;
_logger.info('Starting shutdown sequence');
try {
for (var phase in ShutdownPhase.values) {
await _executePhase(phase);
}
_isShutdown = true;
_logger.info('Shutdown complete');
} catch (e, stack) {
_logger.severe('Shutdown failed', e, stack);
rethrow;
} finally {
await _shutdownController.close();
}
}