close db automatically, fix kvdb:close/1, auto log_dir