Cinnamon is supposed to kill the fungus they live on. Cloves also. Tea dilluted in water. You have to keep reapplying. You forget and they come back!!!
It's not clear to me that fungus gnats in your compost are really a problem, other than being suggestive that your compost may be a bit on the wet side.
I would not personally worry about them, unless this compost is destined to be used unsterilized for indoor containers or something like that.