Fixed potential shutdown crash bug