Tweak a little the task cancel code.