Corrected the killing of a thread due to a useful review by @agentzh
It seems that this makes kill_sleeping unnecessary, so it was removed.