If your sure it's fruit flies and not fungus gnats.. Fruit flies can start buzzing around poorly composted soil which contains kitchen scraps, but otherwise, fruit flies are uncommon in the grow room unless there’s ripe/rotting fruit or other tasty bits for them to eat.
So once you get rid of their food, the fruit flies will disappear. If it's fungus gnats some yellow sticky traps help and so can a neem oil spray solution.
Happy Growing! 👊