Lua: Teleporting the player while menus are open crashes the game

I've been working on porting the MOP asset review tool to OpenMW. It's just a simple UI that lets you find all usages of an asset and teleport to them.

Unfortunately it seems the act of teleporting from within a menu causes an instant CTD in OpenMW so I've hit a road block.

As a workaround, I tried force closing the UI before teleporting. This does solve the crash, but afterwards the UI becomes broken and non-interactive:

I've attached a simplified version of the UI with just a single teleport button that causes the CTD.

Steps to reproduce

(1) Enable the attached example mod.
(2) Load a save file.
(3) Open the "Teleport Crash" MCM menu and click the button.

TeleportCrash.zip

Edited by G7