# A question on wolframscript

I'm trying to run a wolframscript by run

RunProcess[{"wolframscript", "-file","my/script/file.wl"}];


The script file is too lengthy to be presented here. At the end of the script, I add

\$Output=OpenWrite["my/file"];
Print["mymessage"];
Exit[];


The message "mymessage" can be seen in "my/file", which shows that the script is run over. However, the runprocess doesn't stop. Does anyone meet similar problem?

• Maybe related, I often run .m scripts on the terminal with wolfram -script file.m. I do experience that the process randomly does not finish after fully executing the script. However, I am using parallel kernels and adding CloseKernels[]; before Exit[]; helped in my case to make the process finish in about 80% of all executions. – Felix Feb 10 '17 at 3:54
• @Felix Thanks very much. In fact, I'm also using parallel kernels. I try to add CloseKernels[] at the end of the script, as you suggested. However, it seems that is doesn't work in my case. – Wen Chern Feb 10 '17 at 4:17
• Well, then I don't know what it could be, but I'm curious to see what other people will say. However, I recommend that you try to create a simple dummy script that can reproduce the effect and post it here. – Felix Feb 10 '17 at 4:25
• @ Felix Thanks again. In fact another package (called "FIRE") is imported in the script. I'm not very familiar with the detail of this package, so I've no idea how to simplify the script to reproduce the effect. However. I try to turn off parallel mapping. The problem persists. – Wen Chern Feb 10 '17 at 4:48
• @ Felix Sorry for that I didn't correctly turn off parallel mapping in this package before. After I do it correctly, the problem doesn't occur any more. Thanks you very much. – Wen Chern Feb 10 '17 at 5:11