fixed exception when cancelling tasks