This isn’t quite accurate. There are other tests that come into play, including whether you own a house in the UK, and how long you spent outside the UK for the rest of the year (and the preceding years).
Basically if you live in the UK, then spend 180 days (or even a whole year) outside the UK but then immediately return HMRC is not going to consider you a non-resident for that period.
It is worth paying for tax advice before you leave because the rules are complicated and there are other factors aside from just not being in the country.