Fail-safe when using sonar

I’m flying an Automode with sonar mounted face down and Terrain following.

If the battery failsafe is activated during autonomous flight, the drone will rise permanently.

RTL altitude is set to 3m and Terrain following altitude is set to 5m.
The effective distance of the sonar is set to 20cm to 6m.
What is the cause?

Also, the Terrain Following (in Auto, Guided, etc) page says “Do not set the EK2_ALT_SOURCE or EK3_ALT_SOURCE parameters. These parameters should be left at These parameters should be left at “0” (barometer).
Do not set the EK2_RNG_USE_HGT or EK3_RNG_USE_HGT parameters. These parameters should be left at “-1”.”
What happens if I set EK2_ALT_SOURCE to 2 (GPS)?