bug-65: close db and cursor if missing