Handle task manager shutdown more correctly

If a task manager was stopped with tasks in queue, they would
not be processed.  This could result in deadlocked threads if
one of the long-running threads was waiting on a task while
the main thread shut down a manager.

Change-Id: I3f58c599d472d134984e63b41e9d493be9e9d70b
Merge "Handle task manager shutdown more correctly"