Fix close db cursors