terminate simulation and race condition fixed