added better stopping of child threads