await
Waits for value as await does in a script. A promise comes back as what it fulfils with, and a rejection as the JsError it carries. Any other thenable is resolved the way a promise resolves it, so a thenable that answers with a promise comes back as that promise's value. A value that is not thenable comes straight back.
Closing the engine while this waits ends the wait with IllegalStateException, since nothing can settle the promise any more.