Fix shutdown crash