Make sure sync running flag is reset even if the task failed