joining thread to stop hanging python processes