there is no way legally, assuming you are talking about a house or flat purchase. If you exchange to buy, and then don't complete, the seller can keep the deposit. If their loss is bigger than the deposit then they can sue you for the balance. This doesn't often happen - but it did on the big new build houses in the last recession.
As noddy said, they might be nice to you. But you can't compel them to give it back.