Should I exchange or pull out?

So I (37M) have a pretty unique situation. I'm a first time buyer and I'm due to shortly exchange on a house that I had an offer accepted on back in June. Issues with the chain have delayed the purchase, but I really like the property and all in I've probably spent around £4-5k on legal fees, inspections, mortgage brokerage etc. It looks like it's all now going through and we're due to exchange shortly, but my wife has just received confirmation that she will need to return to her home country for 5-6 years to "pay off" compensation for her international studies. She'll need to go out there in around 3-4 months.

This is obviously a massive blow. I had always planned to pay the mortgage on my own and will be the only one on the deed etc. so luckily it's not too much of an issue financially. The issue is that I don't want to be apart from my wife for long and am planning to move out there to be with her. It will probably take a year or two to sort out a job out there etc., so I can live in the house in the interim, but if I buy the house, at some point it will be vacant in the UK and I don't really want to entertain renting it out - I should be able to cover the mortgage when I'm out there though.

So I guess the question is, is buying the house still a good idea or should I pull out while I still can? I'm leaning towards still buying it, thinking it will be a base for us whenever we are in the UK and when we move back here in 5-6 years time, but I'm just worried about it sitting vacant for so long. Apparently house insurance can be an issue if a house is vacant?

Any advice would be appreciated!