Fix wait_task_completion