You are lucky in the fact that they are allowing you to turn in a resignation and will give you a reference. It would be much harder to find a job with a termination and no reference.
I understand your pain. I've been through a similar experience myself a couple of years ago. Remember that God does not close a door without opening a window. It took me several months to get a new job but when I did it was much better, better pay, better benefits. I now feel blessed.