stop method
Stops the program with interrupt and waits up to timeout for it to
finish writing, then kills it.
Implementation
Future<void> stop(Duration timeout) async {
if (hasExited) return;
interrupt();
await exited.timeout(
timeout,
onTimeout: () {
kill();
},
);
}