I didn’t even know about that.
https://www.hdb.gov.sg/residential/living-in-an-hdb-flat/for...
But yeah, you basically sell whatever years of your 99 year lease you don’t need (calculated off the youngest occupant, so a 40 year old only needs 50 years of housing). Government gives you lump sum for your CPF, which you convert to an annuity at retirement for an income stream.
But you’re right, with family, typically the kids take over the HDB and living expenses for their parent. They get the HDB when the parent passes.