fixed stopping of threads