Application doesn't close inside flatpak, but local build works

Doesn’t sound like a Flatpak issue to me.

You mentioned that you tested:

  • WSL with Ubuntu and X11
  • Fedora with Wayland

So, this could be just an issue with your Wayland code (assuming you have Wayland support), like not releasing the window after closing the game…

So, it would be good to first test if this is reproduceable under Fedora with X11 as well.

If you want to check under Flatpak as well, you could use the arguments --nosocket and --socket to force one system.

For example,

flatpak run --nosocket=x11 --nosocket=fallback-x11 --socket=wayland APP_ID

would give the app only access to the Wayland server, while

flatpak run --socket=x11 --nosocket=fallback-x11 --nosocket=wayland APP_ID

would only provide the app with X11.