Hair turns gray because the pigment-producing cells in hair follicles, called melanocytes, gradually reduce their production of melanin, the pigment responsible for hair color. As people age, these melanocytes either die or lose their ability to produce melanin, resulting in new hair growing in with less or no pigment, which appears gray or white. Genetics mostly determine when this process starts, usually around the 30s or 40s, but environmental factors like stress, smoking, pollution, and overall lifestyle can accelerate the graying process. Stress may cause melanocytes to move out of hair follicles, contributing to premature graying. Additionally, a buildup of hydrogen peroxide in hair follicles, which increases with age, can bleach the hair internally, contributing to gray hair appearance.