When Artists Break Up With Their Galleries, Who Gets What?

When a long-term relationship comes to an end, what is the fallout? Who gets the unsold art? And what if the gallery has invested in the production of work that is still in its possession?