juanitos said:the above methods are good for controlling the infestation.
To actually end it you should use Bacillus thuringiensis israelensis (Bti) brand name mosquito bits / dunks.
Bti is bacteria which is food for fungus gnat larvae (and other Dipterans), it has a poisonous effect on them that kills the larvae after they eat it.
this ensures they do not grow up to breed, stopping the cycle of reproduction, eventually ending the infestation.
It is not instant, the larvae have to eat it and it gradually kills them. Adult gnats are not effected.
So as it is working there is nothing really to do or see, so some people don't appreciate it
but it is really the most effective way to end the infestation.
the life cycle of a fungus gnat is 3-4 weeks. so no matter which method you use, you need to be patient and keep doing your control methods for at least that long.
even if you kill every adult, there are more larvae chillin in your soil feeding on your plants roots and eggs waiting to hatch.
a nice thing is Bti has no effect on other organisms / plants. so you can apply it into your water or mix a bit into your soil as a preventative even if you know you're setup is prone to getting fungus gnats.
This is what I do. Works great.