My bet is at the convention. He gets the nomination, but then cannot accept it due to (fill in the blank). Once he steps down the delegates can make an appointment and fill the vacancy.
I bet it doesn’t happen until around the convention too, but he wont yield. If there isn’t basically a democrat coup behind the scenes to force him, then he wont go. The ego is the last part of the brain to go.