If there isn't enough cash in the estate or enough assets in the estate to pay all of the expenses, all the debts, all the required expenditures, then your state's law will show you a chart as to which debts take priority.
So it's much like when you file a bankruptcy, where there's not enough assets to go around, the courts will decide who gets what and in what share.