Add context manager to close database connection