Fix shutdown method