Resolve bug so now the threads exit ok every time