Thanks! It helps me understand why I can't receive onDisappear.
After try your code, I still has a scenario that can't be solved.
Open a Window.
Open a ImmersiveSpace from window, window still exists.
Tap the close X button below the Hello World window. Window disappear but ImmersiveSpace still exist.
I didn't recieve onDisappear or inactive/background from ScenePhase. How can I know the Window is closed? I want to reopen the window but I don't know whether it is closed.