Fix issue where completion of the task and logging occurs many times.