Fix a Cursor leak

When cursor is done, the cursor must be closed to avoid cursor leak.