I can help out here - my account is with Fidelity, so though I'm pretty sure what I'm describing is general industry practice, all I know for sure is its the agreement between me and Fidelity
In order to short stock, the entity selling to open will deposit cash equal to the value of the shares they borrow (at that day's price) in what ends up at a 4th party bank (me, my broker that is lending my shares to the short, the short, and then a 4th party). They hold the cash that is the ultimate back stop for both me and my broker. That amount on deposit goes up and down each day with the share price.
The short's broker will also then require them to keep some incremental cash in their account (margin) that ensures the short can pay for buying back the stock if required to do so.
All of this is to ensure that the broker that borrows my shares, can return my shares. Because I don't lend my shares out to whoever - I lend my shares to my broker, Fidelity, and if they can't return what they borrowed from me on demand / when required, then it's Fidelity that is defaulting - not the entity that Fidelity lends my shares to.
As
@ggr says, it'd be a major failure by the entire system.
It means I would get 102% of the closing price of the stock yesterday (the cash on deposit with the 4th entity - remember we're positing a situation where Fidelity has defaulted and is bankrupt - they really want to avoid that).
Personally, I'm satisfied with the safeguards in place that ensures I get back my stock, rather than receiving back cash. Cash is only a backstop that ensures I'm made whole without having to wait through Fidelity's bankruptcy proceedings.