Fix shutdown on exit