What flies are we talking about here? Fruit flies or larger flies like houseflies and blue bottle flies?
For fruit flies there's no need to refrigerate them. Just give the lid a good tap or two, open the lid, tap on the bottom to get a couple flies out, tap again to make them fall back down and...