close method
Ends the app once what is committed is written: the region is cleared and the terminal restored. Completes once it is, with the error that ended the app where one did; calling it again waits for the same.
Implementation
Future<void> close() async {
if (!_ended && !_closing) {
_closing = true;
// the frames that build what is committed come first
while (_pending.isNotEmpty && !_ended) {
await Future.any([
Future.wait([for (final c in _pending) c.written.future]),
done,
]);
}
_binding.quit();
}
return done;
}