safe close db if kill