How to avoid fruit flies getting out?

While feeding they always get out. Is there a solution for handling them that keeps them in their place?