Automated flight lose control geofence violation and crash

Hi Guys,
we are flying black cube flight controllers to make automated flights using 3rd party software. my main problem is sometimes uav leaves its route and flies to another direction , i have a RTL geofence but it never works , uav continues to fly , finally it reaches hardfence and motors disarm , uav crashes.
im expecting this is a battery problem when battery is lower ,all control from ground is being lost. uav gets into a kind of failsafe mode and stops trying to turn back. in the link i uploaded crash logs that can be viewed , i want to find how to teach drone at least landing at position using gps , we are using F9P ublox with rtk. ,n the logs gps is just fine no problem with signal.


any answer regarding this behaviour ?