Merge "Wait for threads to finish before returning." into oc-dev am: aedcedfa85
am: a4fc619868

Change-Id: I71b758a55e6a81f606f2e1e33a3ae6c161851344