One suggestion, yet not the best method, is to catch a GMSH error. A proper mechanical ending criterion would be better.