How to close WebGL

How can one close webgl app and free resources without refreshing the page?
Application.Quit() isn’t working. Removing canvas just hides scene. Setting Module.noExitRuntime = false and calling Module.exit(0) freezes firefox.
_emscripten_cancel_main_loop() seems just pauses the loop with no memory freed.

Same issue here