Close internal cursor during finialize to prevent leaking