In humid conditions, hot soot particles rising from a fire can carry an electrical charge, as can the molecules of moist air around them. Concentrating them together from a locomotive chimney in the presence of steam will increase the effect. There is then the possibility of a discharge if the charge builds up.
It is believed in a couple of cases that a discharge of this sort, earthed into the chimney and setting alight the soot deposits inside it, may well have caused locomotives to explode.
The physics is rusty, someone may be able to do better.