public void Close() {
		// Wait for background work to finish
		mutex_.lock();
		// shutting_down_.Release_Store(this); // Any non-NULL value is ok
		while (bg_compaction_scheduled_) {
			try {
				bg_cv_.await();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		mutex_.unlock();

		if (db_lock_ != null) {
			env_.UnlockFile(db_lock_);
		}

		versions_.Close();// close the files
		versions_ = null;
		if (mem_ != null)
			mem_.Unref();
		if (imm_ != null)
			imm_.Unref();
		tmp_batch_ = null;
		log_ = null;
		if (logfile_ != null) {
			logfile_.Close();
			logfile_ = null;
		}

		// wlu, 2012-6-2, need to destroy yhe cache
		table_cache_.Destroy();
		table_cache_ = null;

		if (owns_info_log_) {
			options_.info_log.Close();
			options_.info_log = null;
		}
		// wlu,
		if (options_.info_log != null) {
			options_.info_log.Close();
		}

		if (owns_cache_) {
			options_.block_cache = null;
		}

		// terminate the scheduled threads
		env_.EndSchedule();

	}