Need to close pgcursor before the rollback.