Fix daemonizing and PID file handling when the daemon did not shutdown correctly.