Fix conditional task stopping.