I used to get things like this when I had stupidly set Recount to record maximum data about every fight, not just boss. Needless to say, logging out took a while, to the point that things would completely freeze. In fact, had I waited (several minutes!), it would have eventually exited (and caused an error next time I logged on, but that's another matter). So do you have an addon saving ungodly amounts of data on exit?
On the other hand, it could be something totally unrelated that freezes your computer and it happens at the wrong time?
I've learned the hard way to back up my WTF folder.