You have me confused. How can you terminate the script in a way that allows it to output to a file? You need to describe in exact detail how this third party script runs. Maybe you are looking to put the process in the background, i.e. a background process?
in reply to Re^2: How to call a script interactively from perl
in thread How to call a script interactively from perl