Fix closed cursor access.