Matt Levine's analysis [1,2] are (imo) good places to get a sense of the issues around this - his commentary on the legal, financial and commercial aspects is illuminating, and entertainingly so.
Based on his analysis, it does seem like Musk really has succeeded in shooting himself in the foot. There was a recent decision, again covered by Matt Levine, in the Delaware Chancery, where (from what I can understand), in a similar situation, the Chancery compelled the buyer to complete the purchase, notwithstanding their attempts to exit the agreement [3].
[1] https://www.bloomberg.com/opinion/articles/2022-07-09/elon-s...
[2] https://www.bloomberg.com/opinion/articles/2022-07-11/the-pr...
[3] https://www.bloomberg.com/opinion/articles/2022-07-12/i-was-...