The problem could be with the NearestObject function, but I blelieve that your problem is in the ?GL7 (Distance _Closest) <= 50 condition.
My computer gets some problems when using, it, as 50 doesn't always mean 50. If i have an object that is 1000m away from some point. and I write ?_Unit Distance GetMarkerPos _Marker < 2000 : _Unit Setdammage 1.0. The unit doesn't always die. But if i increase 2000 to 4000, it kills the unit. My solution to your problem, would be to use the distance formula directly into your script.
Something like this
?(((Getpos _Unit Select 0) - (GetPos _Pos Select 0))^2 + ((GetPos _Unit Select 1) - (GetPos _Pos Select 1))^2 + ((GetPos _Unit Select 2) - (Getpos _Pos Select 2))^2)^(1/2) >= 50 : Exec "MyScript.sqs"
May be a bit lengthy, but it will also get the distance of height above the ground.