How to detect when VR session ends?

Can WLE be able to tell if you leave the immersive session and back to flat?

Yes, WL.onXRSesssionEnd.push(callback)