Add a file-based debug hook.
Fix detection of : use numeric evaluation instead of test -n.
Correctly stop the daemon when in systemd mode.

Systemd reports daemons as "stopped" when they are in process of
shutting down. Handle this.
Actually, systemd does not commit a stop if a service was not running,
so it is relatively safe to assume that we were previously running
if we seem to be called from the systemd stop/halt sequence.