added clean shutdown