Fixes for running under systemd

Hanoverd running under systemd exited immediately because stdin was not
connected.

Also, SIGTERM resulted in an unclean shutdown.

This PR fixes both of these issues.