Oh dear, yes, it happened to me. And many others if you look on the long 'Help Calm me - house buying and selling stress' forum in House and Home.
Mine was so far towards the end, that I actually had a rep from a removal company with me when my Estate Agent came round, to tell me that the purchasers had pulled out. She asked for one month to try to re-sell it - I was dubious, and exhausted, but agreed. Four days later she sold it at a £4,500 than the one that pulled out.
I did pull out of the flat I had been intending to purchase at that point, but then another one that I had looked at months earlier (but was slightly out of my financial reach) reduced its asking price by ten grand and then (after a quick dash to re-view it) agreed a further ten grand deduction.
So, that withdrawal by those purchasers ended up very happily for me, getting the preferred flat for myself and nearly fifteen grand better off!!!
It is difficult at the time, to be optimistic - but do try. Hopefully, you will end up joining those of us who survived that horrible experience.
Good Luck