There is no way to completely eliminate the ambient background sounds or ambient reflections recorded on set, whether indoors or outdoors.
A shotgun mic has (or should have) terrific off-axis rejection. If it is used in a noisy environment outdoors it will pick up a lot of the ambient sound. The skill with which a shotgun mic is aimed will reduce, but never eliminate, the amount of ambient sound present in the production dialog tracks. However, since the source of the ambient sounds can (most times) be seen it can be "buried" in a carefully constructed sonic ambient background during audio post production. There is also the option of using dialog from alt/unused production sound dialog (close-ups and two shots, etc.) where the ambient sound from the outdoor set is less prevalent, and judicious use of noise reduction can further reduce the amount of ambient background noise recorded during production.
If a shotgun mic is aimed with skill, and the set is properly prepared, the reflections that are so prominent in indoor sets can also be significantly reduced, but never entirely eliminated. And the dialog editing process still plays an important role, substituting the dialog from close-ups and two shots for the dialog in wide shots.
As I have mentioned with boring frequency, it is the skill with which the tools are used that ultimately makes the difference. If the mic is properly aimed, and if the dialog is carefully edited, and if the ambient sound bed is created skillfully, and if noise reduction is used properly, the ambient sound recorded on the set with the production dialog will be controlled, quite seamless and unnoticeable to the average member of the audience.