Re:Ask HN: Why do langs with alleged “automatic memory manag...
by ErotemeObelus on Thursday July 18, 2019 @05:16PM
(#20473993)
Yes, you're correct that os's have some kind of rudimentary reference counting for files, but it's very inchoate and not designed as the primary method of handling file references.
Btw, the os closes any open file when the program ends.