To answer your question. First, have you talked to your Realtor? He/she is the one to advise you on canceling the purchase agreement. You (the buyer) can cancel the purchase agreement. Your Realtor will give you a document to sign stating reason to cancel. The Seller must agree to the cancellation. Your Realtor will negotiate the earnest money with the Seller's agent. The Seller has three options: 1. Release you from the PA and return earnest money to you. 2. Release you from the PA and request the earnest money be given to them. 3. Will not release you from the PA or the earnest money which makes you go into limbo and you would have to go to mediation to settle the issue. Normally the Seller will release you from the PA but want the earnest money.
First thing you must do is notify your Realtor that there might be a change in your lifestyle. Your Realtor will direct you to the proper procedures to cancel the PA.
I am sorry to hear about your possible separation/divorce. I hope everything turns out for you.
I'm sorry for your situation. Your contract is the place to go for answers to this question. If you are not confident in reading and understanding it, start with your agent and if still not sure get an attorney.
Chances are your earnest money is primarily what is at risk. You may have legitimate exits through other addendum such as inspection or financing contingencies. Read over your rights and obligations and discuss your options with your agent. I hope things go better for you.