I agree with what John T posted below about the taxes being paid as part of the process of transfering a clear title - similar to selling a house that has a mortage on it - the mortgage holder gets paid before (or at the same time as) the seller.
The trust's gain on the property has nothing to do with how the funds are distributed from the sale. If the sales price is more than your basis you owe capital gains taxes.
If I buy a land for $100,000 and then borrow another $50,000 against it and later sell it for $140,000 I owe capital gains on the $40,000. The fact that I have am $10,000 short in paying off the loans means nothing.