How do you tell if a raycast hits the underside of a terrain?

When my camera moves into or under the terrain it becomes transparent. The issue is my UI raycast code still hits the transparent underside messing up my UI.

Tried

 Ray mouseTrackingRay = Camera.main.ScreenPointToRay(mouseTrackingVector);
        Physics.Raycast(mouseTrackingRay, out mouseTrackingHit);
        Debug.Log(mouseTrackingHit.normal); //Same result for both sides :(

any advice on how to detect or filter this out?

Done a workaround by
-Raycast alll
-Sort by Distance.
-If ((fist hit=terrain) and (distance small) and (more than one hit)) then go for secound hit.

 Ray mouseTrackingRay = Camera.main.ScreenPointToRay(mouseTrackingVector);
        RaycastHit[] rayHits = Physics.RaycastAll(mouseTrackingRay).OrderBy(h => h.distance).ToArray(); // sort by distance.
        if (rayHits.Length > 0)
        {
            //Debug.Log("name=" + rayHits[0].transform.gameObject.name + " distance=" + rayHits[0].distance);
            if ((rayHits[0].transform.gameObject.name == "Terrain") && (rayHits[0].distance < 13) && (rayHits.Length > 1))
                mouseTrackingHit = rayHits[1]; // ignore first hit.
            else
                mouseTrackingHit = rayHits[0]; //
        }