Don't try to terminate, process already closed
Add locks for correct handling of multithreading
Reduce log output