Fixes shutdown issue with TaskExecutor

where a shutdown caused by task failure might not be able to complete.
Merge pull request #3667 from tinwelint/2.2-bip-task-error-fix

Fixes shutdown issue with TaskExecutor