The belief that nervous shock can cause you to go grey overnight (medically termed canities subita) is one of those tales that could nearly be true. There are certainly cases in medical literature of rapid greying over quite short periods of time. And reported cases go back to antiquity including such legendary figures as Thomas More and Marie Antoinette.
The biology of the phenomenon suggests that a mixture of hormones and cognitive bias is responsible for the myth.
There is little doubt that plausible biological mechanisms exist to account for emotional stress potentially affecting hair growth.
Human hair cycles between a growth phase (anagen), a resting phase (catagen) and a dormant phase (telogen). Pigment is produced by the hair follicle to colour the hair during the anagen phase while it is growing.
The length of the anagen phase varies according to your genes and certain hormonal levels. It can be anything between two years and eight years. When the follicle receives orders to end the anagen phase, it stops producing hair and begins to prepare for telogen. The telogen phase lasts between six and 18 months before heading back into anagen.