You can leave a room as the app goes to background using the Unreal Engine’s feature.
When a mobile app that uses STRIX goes to background, it is usually disconnected from the server and leaves the room. The time before the actual disconnection differs for the OS and its version, and if it is Android, also depends on the manufacturer or the model, but anyway it will be in a second to about 2 minutes.
Unreal Engine has a class called Platform Game Instance. You can detect transition to and from the background state by using it (or its derived class) as the game instance. When an app goes to background, Application Will Enter Background Delegate is executed, and when it returns, Application Has Entered Foreground Delegate is.
You can use Application Will Enter Background Delegate to shorten the delay before leaving. Call Leave Room when the app goes to background so that it leaves the room without waiting for disconnection.
When getting back from background to active state, the client is not in a room and replicas have been deleted. It can’t just continue playing. You need to perform an appropriate handling such as joining the same room as before again or transit to another appropriate scene (such as the home scene), utilizing Application Has Entered Foreground Delegate.
Consult your Unreal Engine documentation for details on Platform Game Instance.