Added logging of the end of ouputting query results.