Properly close database session on /n/ API query.

Otherwise the open session blocks the test database teardown when testing this
stuff.