Fixes shutdown issue with TaskExecutor

where a shutdown caused by task failure might not be able to complete.
What about checking <code>shutdown</code> before calling <code>shutdown0</code>? In that way we can try to avoid having many threads blocked on the <code>shutdown0</code> for no reason.

I would also set <code>this.shutDown = true</code> immediately after the check in order to minimize the race window between the check and the change of the value.