init scripts: Fix bug with writing PID files