Fixed a bug where thread tried to kill already dead thread