As a concrete example for the UK: I had an ISA (a tax-exempt share account) with a UK financial institution which went bust. The brokerage had correctly kept client and its own money separated, but it had burnt through all of its own money by the time it went into administration. Somebody has to pay the administrator's fees for correctly winding up the business and returning everybody's shares to them, and that somebody, it turns out, is the clients, if the finiancial institution itself has no assets left. Luckily the UK has a compensation scheme for individual private investors and the cost-per-client of the administration was less than the scheme limit, so effectively the result was "the government paid for this", so in the end I was not financially out any money. However, I did end up without access to the shares for the best part of a year until the administrator had found another brokerage willing to take on the customer base and the share holdings were transferred over.
https://www.fscs.org.uk/making-a-claim/failed-firms/beaufort... is the FSCS page on the firm. It cost the FSCS 27 million quid in total, apparently: https://www.ftadviser.com/regulation/2022/02/18/fscs-pays-ou...