Modified sth close timing for using in end_query() and in fetch_id(). bugid:111814