waitpid before exit from main process. kill KILL on Windows.