Ensure we aren't writing to a closed leveldb database

I've been seeing more segfaults recently and I wanted to ensure that we aren't trying to use a leveldb handle after it's been closed.
Should probably do (locking running) here; multiple threads could .close concurrently.