Yugoslavia broke into several smaller countries following the death of the Yugoslavian dictator, and a huge war ensued. Maintaining the domain records was probably quite a low priority.
The organization that ran the nameservers for .yu still exists today. Even in the case where there was no one fit to run them, all the records could be transferred to ICANN or someone else to run the server.
.yu was purchasable long after the country ceased to exist, until 2008 to be exact.
Technically speaking, "Yugoslavia" continued to exist until 2003, when the name finally got deprecated in favour of "Serbia & Montenegro" as one country (also including the territory of Kosovo), which itself only lasted 3 years before Montenegro declared independence (and Kosovo did the same 2 years after).
So however you spin it, the domain outlived the country by at least 5 years, arguably 15(ish), 9 of which were post-war(s).