[[ Bugfix 12890 ]] Use the correct unref for cursors