Fixed crash in case database is closed but tabs is still opened