This is one of the best things about an HSA: it's yours! Your HSA is yours and yours alone. It is yours to keep, even if you resign, are terminated, retire from, or change your job. You keep your HSA and all the money in it, but keep in mind that there may be nominal bank fees if you are no longer enrolled in your HSA through your employer.
You can even use your HSA to pay for long-term care insurance, COBRA premiums, or other health insurance premiums if you’re receiving unemployment benefits.