While it isn’t always necessary, a nonflammable contact cleaner would be the safest option if the vapors or liquid could be exposed to sparks, open flames, or hot surfaces. Of course, when the electrical device is powered, there is a much great potential for sparks.
Many commercially available contact cleaners contain alcohols and hydrocarbon solvents, which are very flammable. They are economical and effective cleaners, but can pose a safety hazard without proper ventilation, and if there are open flames, sparks (e.g. welding process), or hot surfaces nearby. Nonflammable contact cleaners are available to avoid these safety issues.