I understand that if you want to cash out your HSA you are expected to pay tax and some penalty on that money. The tax part I understand. But what is this penalty exactly and how much would it be? And if a person is leaving the country permanently why should they have to pay penalty for withdrawing their own contributions from the HSA? Can it be avoided? Just curious. Thanks.
Looks like it is a 20% penalty on the withdrawal (along with income tax).
Funds can be withdrawn for any reason, but withdrawals that are not for documented qualified medical expenses are subject to income taxes and a 20% penalty. The 20% tax penalty is waived for persons who have reached the age of 65 or have become disabled at the time of the withdrawal. Then, only income tax is paid on the withdrawal
Even though you are leaving the country, you still earned and contributed to the plan while you were working/living, so it is still subject to the taxes/laws in place.
On a somewhat related note, check out this question here, as it may help you out a bit (similar but not really duplicate) - How do I withdraw all money from my HSA account as a non-resident?