Fixed clean shutdown of processes