One Thrift Savings Plan consideration for those nearing retirement is the status of any loans they have taken from their TSP accounts. While it’s generally known that loans may not be taken out after separation, there’s a potential tax trap for those who have an outstanding loan when they retire.

TSP loans fall into two categories. Loans for the purchase of a primary residence can be amortized over as many as 15 years. General purpose loans—which require no stated purpose—can be amortized over as many as five years. They are taken out proportionately from traditional (pre-tax) balances and from Roth (after-tax) balances, for those who have invested in both types.

Loans are repaid through payroll allotments over the payment period specified in the loan agreement. You can prepay the loan in part or in full before the end of your loan repayment schedule without penalty.

If you leave service with an outstanding TSP loan, you must repay the loan in full, including interest. If you have not made that payment within 90 days, a “taxable distribution” of the unpaid loan amount attributable to traditional investments will be declared.

Since that type of balance likely is by far the larger portion of the loan even if you have a Roth balance, that could subject you to significant tax penalties. A delay in repaying a loan also may affect the processing of a withdrawal.

Those who find a need for a lump-sum of money late in their working careers might want to consider taking out an age-based in-service withdrawal rather than a loan, so long as they are at least age 59 ½. After that age, there is no early withdrawal tax penalty for taking out an in-service withdrawal. However, those who take out such a withdrawal will not be eligible for a partial withdrawal post-separation.