Fungus gnats come from watering too much / too often, resulting in soil that never really dries out.
As an emergency fix, you can put a one-inch layer of fine sand on top of your soil. The sand helps prevent the larvae from reaching the surface when they hatch and they'll eventually die out, assuming you get your watering under control.
What is your watering routine?