In the "Sinks" library, there is a block called "Stop Simulation". You can construct a logic (e.g. compare your output against 10e-5). If the logic is true, it will stop the simulation.
You can set your simulation's stop time as inf (infinite) and rely on the logic to stop the simulation. If you log the simulation time "tout", you can find out what exact time it stopped.