destroyAndAwaitExit

suspend fun Process.destroyAndAwaitExit(gracePeriodMillis: Long, killTimeoutMillis: Long): Boolean

Terminates the process, then waits until it has actually gone.

Process.destroy only requests termination: it returns immediately, and it does not reach the browser's child processes. Those children keep open handles on the profile directory, so a browser started on the same --user-data-dir shortly afterwards cannot take ownership of it: it hangs before opening its debug port, and the start times out with no visible cause. Callers therefore need to know the browser is really gone, not merely that it was asked to leave.

Grace-waits for gracePeriodMillis, then escalates to killTree and waits up to killTimeoutMillis more. The same shape as zendriver's Browser.stop.

Return

true if the process exited, false if it was still alive when the timeouts elapsed.