First of all, the simulation is not freezing when the window opens. The Method execution will continue, and Plant Simulation will automatically close the window when the Method execution has finished.
You can use the function setInfiniteLoopDetectionTimeout to set the number of seconds after which Plant Simulation will open the window. If you call the function with 0, the infinite loop detection will be disabled entirely.
setInfiniteLoopDetectionTimeout is the only way to set the timeout. The function returns the old value. You cannot change this setting interactively.