Fix tests exit race condition (#60757)
This ensures we don't allow a following exit condition to override a
previous as async work is done before the `process.exit` actually occurs
so a follow-up one could override the first giving a false negative.
Closes NEXT-1911