Question: Stop a loop when face an error

I want to stop the following loop when there is no more roots. how can i do this?

 

 

Please Wait...