fix some cursor.close() bugs