started code to terminate process when output window closed
needs testing