Close sockets on DB error

Also work around a sockjs-node bug. This might be related to issue #25? Though
it doesn't explain everything I've seen.