Normally, when the learner closes the browser tab, the SCORM package will automatically call the SCORM API to terminate the session properly.
If you want to add a custom “Exit” button for learners to manually terminate the content, you can use: prez.destroy();
This method will call the SCORM API to terminate the session and also remove the SCORM content from the page so it is no longer displayed.
If you also want to try closing the browser tab/window, you can additionally use: window.top.close();
Since the content is running inside an iframe, window.top is used to access the top-level browser frame.
We do not recommend calling the SCORM API directly in custom code because it may lead to compatibility or maintenance issues later. For example, if you switch to another SCORM version in the future, the code may need to be updated accordingly. Using prez.destroy(); is recommended because ActivePresenter already handles the SCORM termination process internally.