Improved reliability of simulation ending.