fixed issues with normal shutdown