Is there a way to create a legally binding buy back contract?

I have sold 2 (last one being 7ish years ago) and would have taken either one back if necessary but I'm out of state now and it's no longer a realistic option. (One is more than likely passed on by now.) I didn't have a buy back contract but let the folks know that I would if I could if they could not longer keep them. Honestly, didn't truly like either horse and it would have sucked to get either one back, but I don't feel that negates my responsibility to help keep them in a good home.