shutdown method
Full teardown: releases stdin subscriptions, closes event streams, frees native resources. After this, the terminal is unusable — process exit will collect anything left behind.
Implementation
@override
Future<void> shutdown() async {
await restore();
if (!_events.isClosed) await _events.close();
}