fix memory leak in thread group