async function mimicEscapePress(element) {
  element.dispatchEvent(
    new KeyboardEvent('keyup', { key: 'Escape', bubbles: true, composed: true }),
  );
  await aTimeout(0);
}
A small wrapper function that closely mimics an escape press from a user
(prevents common mistakes like no bubbling or keydown)
@param {Element|Document} element