After all contingencies are signed off you can sign the lease. Put an agreement into the lease covering what the damages are if you don’t perform. I would suggest the ammount be enticing enough that the landlord is motivated to sign with you but not more than 2 months rent.That should be somewhat close to or less than the earnest money that you get to keep if the buyer quits after contingency removal.There is no need for your move not to go smoothly. It is too late in your case but frequently the contract terms can be negotiated for the seller to maintain possession for a period of time after the close of escrow.
Good luck.