Fix joining with the threads