At those altitudes the combination of a very high closing speed (air is thin) and the short range of the gun creates a real risk of flying into the target you're trying to hit.
Using the same reasoning, a gun bullet should also be faster with higher altitude, hence have a longer range.