Fixed database query on quit.