Fix old gcc build
Fix broken thread stop handling