KVEngine: make sure dictionaries are closed before dropping them/exiting