Retirement tax questions

You do not "fix" the scenario you described.

 

Capital gains and losses are netted at the trust level and then, in some instances, net gains are passed through to the beneficiaries (assuming the trustee has the authority and/or discretion to do so). 

 

In the event losses exceed gains, they are carried forward to following years until they are absorbed by gains or until the trust terminates.