I'm not sure the OP is saying the 2 loans weren't outstanding at that same time which is what the IRS example highlighted is talking about.
The maximum loan is the lesser of 50% of the vested account balance (minus outstanding loans), or $50,000 reduced by the highest outstanding loan balance in the last 12 months.
It's not 100% clear if the $78,150 above is inclusive of the loan balances - I'm assuming it's not. (if it is, it's still the same answer anyway).
Therefore if the OP pays off loan #2:
50% of the vested account balance reduced by the remaining loan #1 is $37,775 - $104,150 X 50% minus $14,300. (if the $78k includes the loans, the amount here is $24,775).
$50,000 minus the highest outstanding loan balance in the last 12 months is $17,330.
Maximum new loan is $17,330.
With these facts, it would be the same regardless of which loan was paid off or if both loans are paid off.