Restart Scene by EventListener

I want to use GDevelop Games embedded in another Website with some extended Features. Therefore I want to control some functions via external Events. Basically Pause/Resume/Restart.

I created an extension to handle the Events:

// Add Eventlistener for pause
window.addEventListener("pspause", function(){
    //add events for pause
// Add Eventlistener for resume
window.addEventListener("psresume", function(){
    //add events for resume
// Add Eventlistener for Restart
window.addEventListener("psrestart", function(event){
    //add events for restart

The first two work as expected, pausing the game and resuming it on the respective Events. But the line “gdjs.evtTools.runtimeScene.replaceScene(runtimeScene,runtimeScene._name,true);” simply does not work. It doesnt matter if i use the variable or a string containing the scene name.

If the line is called outside the Eventlistener (in the scene or in an extension) it works, but that does not really suit my needs. Can someone please help or suggest a workaround?
Many thanks.