Fixes shutdown issue with TaskExecutor

where a shutdown caused by task failure might not be able to complete.