I launch a child process in Java as follows:
final String[] cmd = {\"\"};
Process process = Runtime.getRuntime().exec(cmd);
>
As you said, addShutdownHook is the way to go.
BUT:
There's no real guarantee that your shutdown hooks are executed if the program terminates. Someone could kill the Java process and in that case your shutdown hook will not be executed. (as said in this SO question)
some of the standard libraries have their own hooks which may run before yours.
beware of deadlocks.
Another possibility would be to wrap your java program in a service.