Fixed unclosed file channels

These unclosed file channels are leaking resources in the case where the leveldb is opened, and closed again. It also prevents the deletion of the database directory even after calling db.close().