BUG: SessionDB was not checking for cursors/connections before trying to close them