fix watchdog to ensure correct shutdown and correct restart