Ah, I instinctively thought of KSA when you mentioned other airports.

Shanghai is quite a bit more inviting than RUH, JED, and even AUH. I understand the logic of not wanting to spend money on a hotel since you could have booked a better connection in the first place, but now that you're locked in, that calculus is water under the bridge and now you're confronted with a choice between $50 to enjoy yourself a bit and sleep in a bed v self-imposed misery. In your case, I'd be inclined to head into the city instead of hanging around near the airport. You could theoretically do it without a hotel (e.g. find a 24-hour spa instead).