You are basically stuck.
The only way to do it is through an emergency hardship withdrawal, and you probably would either not meet the criteria, or, if you did, you would end up paying through the nose to do it and it would not be worth doing.
IF you tried to take the balance money out (and you are under retirement age), they only way to do that is to request a hardship withdrawal, which would allow you to take money out of your account, but would then hit you with BOTH taxes at the current tax rate, PLUS an early withdrawal penalty of 10% of the amount, PLUS it would make you stop contributions to your account immediately for a period of time. It is intentionally VERY COSTLY to have to do such an action- so over something as small as $5,000 it is not worth the hassle of doing.
See the "Hardship withdrawal page" for details:
https://www.tsp.gov/planparticipation/inservicewithdrawals/financialHardship.shtml