Swapped kill order to avoid accidental crash

Killing database after main server threads are down to prevent anyone trying to write to the database after it's dead.