Fix shutdown process