Fixed non graceful database closing