Merge "Wait for threads to finish unregistering"