You should discuss this with your lawyer. Whether it's legal or not depends on the wording on your contract. Likely it's not a breach of contract for the seller to back out. Even if it is, there's not much you can do. You can try to initiate a suit for specific performance, but that gets very expensive very quickly.