better handle shutdown race