Fix database quit method