BUG: database closed intempestive