Fix bug when closing pymongo cursor