The phrase “to fly the coop” is American slang, apparently twentieth century, though it is likely that it was criminal cant originally and may date back to the nineteenth century.
“Coop” is slang for prison, jail; the original meaning was, therefore, to escape from prison.
By later extension the phrase has come to mean to depart unceremoniously from any place, especially from a place that has begun to feel confining or restrictive.
Thus a boy at school tells his fellows that he is going “to fly the coop,” when he intends to “play hooky”; that is, to leave the school grounds without permission.
Or, humorously, one at a party that he does not enjoy, is said “to have flown the coop” if he has left without formal leave-taking.