work on correct shutdown