javascript component callback when detached ?

Im a using javascript component.

Like this :
https://vaadin.com/docs/-/part/framework/gwt/gwt-javascript.html#gwt.javascript.rpc

There is a callback to handle when the state change when fields are modified in java.

// Handle changes from the server-side 
this.onStateChange = function() { 
    //Some code
};

I wonder if there is a way to add a callback function when the component will be detached or destroy by vaadin.

Something like this

this.onDetach = function(){
    //My code to properly remove some js features i done
}

Try to define the function as
onUnregister

this.onUnregister = function(){
    //My code to properly remove some js features i done
}

Works fine. Thank you!