The best way to control fungus gnats is to identify any plants that have wet soil and let that soil dry completely before the next watering. This process will kill the larval stages in the soil, and for the adult gnats, they can be removed with a vacuum cleaner from windows and from around the plants.
Gnats feed on plants or fruits, others insects or blood. Their food source must be placed and corrected if possible. Make sure that fruits will not be exposed to open air, keep it inside the refrigerator. It will not only protect the fruit from gnats, it will also prolong the fruit’s period of ripeness.
From Michigan State University Extension, bounce dryer sheets have been found to repel adult fungus gnats in the laboratory. Find out more here.