handling cursor close for cache queries