Loan amount returns to lender's balance when the borrower closes their trade and pays off their loan. How long a loan is taken depends entirely on the borrower.
If your loan is being held for too long, it is possible that the Reinvest checkbox is checked (Lending > Loans). When this happens, your loan will become a loan offer again once it is paid back to you. In a highly active market, this can become an endless cycle. Uncheck the box if you want the loan to simply return to your balance instead (no more loan offer).
We can also recall your loans on your behalf - simply send a support request titled "Recall all my loans" and we'll be happy to assist. Keep in mind that we cannot perform the recall for selective loans, and all loans older than 24 hours will be recalled at once.