Simplify shutdown logic for Connection

* Use a QSocketNotifier listening to stdin to determine when the parent
  process has detached.