You can reproduce this issue like this:
- Run `bin/phd debug hangforever`.
- Kill it with `^C^C`.
- Most of the time, it will emit errors.
With `--trace`, you can see additional information. After this patch, it no longer emits errors but still successfully marks the daemon as exited, and the `willExit` event is always emitted exactly once and emitted last.