Fix potential unreleased tmems

If the tmems are not 0, clear all remaining tmems

Submitted as proxy for Craig Prescott
TRQ-1925
18115