I already did this but it didtn work
GPS stay off When i minimize radardroid app
So, what you really want is for Llama to know when an app stops working in background ("cached"), and no, Llama doesn't support that natively.
There are at least two ways to go around it, though. They both work, but are quite involved. I describe the basic idea here but won't go into all the details because no two phones (or users) are the same. You can set it up to suite your need or to the limitations of your environment.
Method 1: You tell Llama when you no longer need GPS
Basically, your problem is that Llama turns off GPS prematurely when you still need GPS on. So, just add another condition to the event so that Llama turns off GPS only when the app is not in front AND the other condition is met. It can be any condition, as long as you can control it. I personally use a Llama variable.
This is how it works:
Either one of the apps that uses GPS starts > turn on GPS and set a variable "GPS in use" to 1.
All apps that use GPS stop AND "GPS in use" is 0 > turn off GPS.
Create a new event with no conditions > set "GPS in use" to 0, then create a shortcut to this event somewhere easily accessible. when you are done with GPS, run this shortcut then close the app. GPS turns off.
I have a rooted Nexus 5, so I can assign navigation keys functions different from the default. When I long press the back key, it will run a Llama shortcut.
My actual shortcut is a little different, but to cut a long story short, this shortcut will 1) kill the app in front and 2) set "GPS in use" to 0.
Of course, your shortcut can simply turn off GPS instead of setting "GPS in use" to 0, but I do it this way because I can be using more than one app that use GPS and I don't want GPS off until I exit all of these apps. I long press the back key when I am done with GPS. If another app that uses GPS comes up, GPS stays on. I continue pressing back key until all app that use GPS are closed, at which time Llama turns GPS off.