Exit Button Works on Desktop but Leaves a White Screen in the Moodle App (window.close issue)

I added an Exit button to my project. When the user clicks the button, I want to close the window using the following code:

prez.destroy();
window.close();

However, when I click this button inside the Moodle app, the screen stays white instead of closing properly. On a desktop PC, it closes the browser tab as expected.

Is there a solution or recommended approach to handle exiting/closing the content properly in the Moodle app?

Hi,

In the Moodle mobile app, the content is opened inside a WebView, so window.close() does not work like it does in a desktop browser.

Use SCORM finish and a safe fallback instead:

if (typeof doLMSFinish === "function") doLMSFinish();
if (typeof doTerminate === "function") doTerminate();

window.opener ? window.close() : window.history.back();

Regards,