Currently there's no way to completely stop task code execution even if nested in several for-loops.
The way to achieve this would be to have a flag variable like this:
{% assign should_exit_immediately = false %}
{% for product in shop.products %}
{% for variant in product.variants %}
{% if variant.sku == "This is just an example, don't do this in real code" %}
{% assign should_exit_immediately = true %}
{% break %}
{% endif %}
{% endfor %}
{% if should_exit_immediately == true %}{% break %}{% endif %}
{% endfor %}
{% if should_exit_immediately == true %}{% break %}{% endif %}
If there was
{% exit %}
command, it would look like this:
{% for product in shop.products %}
{% for variant in product.variants %}
{% if variant.sku == "This is just an example, don't do this in real code" %}
{% exit %} or {% break_all %} # this is not working obviously
{% endif %}
{% endfor %}
{% endfor %}