(#2293) - Check if database is closed before running operations on it.