Adds extra checking when deleting a task directory