Fix shutdown bug.