Break-even: the number that decides it
Break-even months = closing costs ÷ monthly payment saving. On the first example on this page — refinancing $300,000 at 6.5% with 28 years left, down to 5.75% over 30 years — the payment falls about $190 a month, so $4,000 of costs repay themselves in roughly 21 months.
If you might sell, move or refinance again before that point, the lower payment never pays for itself and the closing costs are simply gone. The break-even is therefore a timeline against how long you expect to hold the new loan, not a verdict on the rate by itself.
After that point the deal flips in your favor: every month the new loan runs past the break-even, the lower payment is money kept rather than costs being repaid. That is why refinancing is really a holding-period question - a borrower staying five more years can justify costs a borrower leaving in one year never could.