Fixed memory leak in handling of process thread handles.