Obligation to keep Swiss health insurance when leaving Switzerland

It depends on a number of factors, the primary ones are whether you’re moving to Europe, and if you are is the country you’re moving to on the list of countries where an application for exemption is possible, and if not, it may come down to how many years into which country’s social security system you paid into the most.
You could try contacting the KVG, but my experience with them was painful.