Bug/switch to db destory

NB, I was about to suggest moving `var dbName` outside of the loop, but remembered JS only has function scope, so under the hood, moves `var dbName` to the top of the function anyway (*hosting*, see [JavaScript variables declare outside or inside loop?](http://stackoverflow.com/questions/3684923/javascript-variables-declare-outside-or-inside-loop)). However, it could be one to document for the style guide.