Hi @leticiarezende,
You can use a return statement to stop the query. The example in the docs uses this to stop the query when i >= rows.length to prevent an infinite loop. For example, using the data in the docs, if you wanted to stop running the query if sales is greater than 500.
if (rows[i].sales > 500) {
console.log("failed check; stopping execution");
return;
}