Ensure cursor is closed