Cherry picked fix on db close