What device, OS and browser version are you using when you experience this issue? Have you tried with another browser?
Have not. This is a 2022 moto g power with Android 12 and Fennec 129.
Chrome will loop the gallery in the same way.
Can't you see the name and the X to close the gallery at the bottom?
What's the default resolution of your phone/browser? (I think you can see that in android settings.
Display size: large Font size: large
Changing these to small works as you describe. When they are set to large the close button is hidden behind the address bar at the bottom of the app window.
With text and window size at default the corners of the close button are barely visible and with great care you can tap it after a couple of tries.
Not sure where to look for xy resolution values.