Move the database closure to the right place

Let's always close the database when we stop the HTTP server, because
there's no reason to keep it open.

Should fix the second half of #2.