The expected migration route for a T2 (General) is to spend two consecutive three-year terms for a total of 6 years and then apply for Indefinite Leave to Remain (ILR). You want to to know if it's necessary to apply for ILR at the end of 6 years.
No. It is not mandatory to apply for ILR, but before you can get another T2 you'll need to undergo the cooling off period. Once the cooling off period has matured, you can return on a T2 again.
The same thing applies if you have 6 years but your gaps outside of the UK do not allow you to qualify for ILR. It's also the same if you do not want to apply for ILR because you may fail a different requirement like criminality or good character.
You can also reset your ILR clock by switching into the family route. And of course you can always return home and apply for entry clearance in a different route.
What all of this amalgamates to is that it is NOT necessary to apply for ILR at the end of your 6 years, but you will have to do something.