Why does my app work in the background

I purchased a Bluetooth enabled GPS receiver and have been developing an app to take data from it, display the data and write to a file.
From what I have read I did not expect the app to work when the screen was turned off, but it does.
The main components are the Bluetooth Client and the Clock.
I had already found that apps using the timer function stop when the screen is off.
Any thoughts

Post a link to it.

Screen / devices is in idle mode or app is closed?

Which Android version?

See also here and here:

To Turn the screen off I press the power button, I do not know what the device does then, but the app keeps running and writing to the file
Closing the app stops it working.

Running Android 9

For how long does your app keep on working after turning the screen off? For how long after the device enters in standby mode by itself?

The thread pointed by @Anke is about keeping the (internal) GPS working with the app in background, what in itself is an issue. Indeed, using an external GPS (as in your case) could be a solution for that as that is active all the time and is not controlled by Android.

I think that the external GPS is the reason my app keeps working. It continuously feeds data over the Bluetooth link with no handshaking. It sends several transactions per second. I greatest time I have had the app running with the screen off is over an hour. I have not found a limit.
I tried using the internal GPS but it would stop when the screen was off.