How to avoid explosion when there is a leakage of LPG gas and coal gas/town gas?
Aside of open flame and operating electronic devices, another danger hard to eliminate is static electricity, mostly due synthetic material of clothes, or rubber soles of shoes.
The safest and the most available prevention choice at emergency scenario is intense ventilation. All others are rather hope it would be enough, as it is hard to eliminate or not to forget all possible ignition sources.
Be aware that switching devices off may be more dangerous than keeping them on, as interrupting high voltage  AC circuit usually creates sparks, unless this is addressed by parallel capacitors. This is typical for devices transforming AC to  low voltage, like most low power electronics.

Coal gas is of little use these days, with major fuel components  carbon monoxide and hydrogen.
Much more common is natural gas, based on methane, or LPG, based on butane (typically 80%) and propane.
The oxidant is in all cases aerial oxygen.