Closing synchronous queries appropriately

Synchronous queries are closed in hive driver, immediately if there is no result or the query result is persisted. If query result is inmemory, the query is closed in hive driver, after fetching the last row.