Move code around in shutdown sequence.

Delete thread pools before detaching the current thread in case tasks
getting deleted need to have access to Thread::Current.

Test: test.py
Change-Id: Icdd222e817dd5b79649cd6d79ca6352683a4de1e
1 file changed