You've got an interesting question here. My guess is that you're shutting down the database well prior to execution of the above method. Most likely before any model code is executed. I believe at the time a model is read via the ruby engine (not necessarily executed) it will connect to the database and it's failing at that point. I hope that made sense.
I'm interested as well in a more detailed answer to this question. But for starters, I believe that's what you're looking at. You may wish to use a more global rescue block to catch the exception occuring early in the process. You should be able to display some diagnostic info from there.