HELOC reduces capital gains

We are selling our primary residence later this year. We have a HELOC on the property that we used to fix up a rental property last year, so we are still in the draw phase. I know the loan payoff on the primary mortgage reduces the cost basis and therefore would reduce the capital gains. With the value of our house skyrocketing over the past 10 years, we most likely will go over the $500k limit for a married couple on excluding capital gains. Does a HELOC payoff at settlement reduce our capital gain? And if so, should we max out the HELOC before we sell, since we are still in the draw period, to reduce this capital gain obligation?