Do you swim in a chlorinated pool? If you do, you will want to protect your gray hair first. One great solution? Wet your hair before going in the pool (dry hair will yellow more quickly than wet hair).
Watch out for your styling tools! Curling irons, blow dryers, and flat irons can all cause gray hair to yellow. Fine gray hair is especially susceptible to yellowing and, unfortunately, yellowing caused by heat or sun damage is permanent.
This is a hard one to avoid if you live in a large city. The best I can tell you is to keep your hair relatively clean and to avoid heavy styling products (like mousses and gels) that attract pollutants.
I saw a photo on Instagram the other day of a woman with gray hair who thought her hair was turning blonde again, and then found out it was actually just turning dark yellow due to product buildup. Yikes!