Switch to a context manager for closing db sessions