moved a database close() so that it doesn't happen to early.