#2051 avoid possible exception: java.lang.IllegalThreadStateException: process hasn't exited which sometimes happens