Stop the simulation after N number of uvm_errors/assertions

Hello,
I was wondering if there’s a way to stop a simulation after a defined number of errors?
For example, if there are 10 uvm errors, there’s no need for me to continue the simulation so I want to terminate it.
Another example is if there are 10 failed assertions, I want to terminate the simulation.

Thank you.

In reply to Ariel Elliassi:

The solution to your problem is simulator independent ,
UVM provides an option of passing a run-time switch :: +UVM_MAX_QUIT_COUNT=10