Fruit flies might leave by themselves if you remove their food. But, this can take a long time because they breed fast. Using a fruit fly trap is a quicker way to get rid of them.