I like the word "stochastically". But I can not really help, because many things can cause a script to crash or freeze. Follow the hints in the manual under "troubleshooting" and try to catch such a freeze event with the DIAG flag. This can give you a hint which part of the script, or maybe which library on your PC, causes the problem.