Fix lingering thread problem.