Re: how to maintain a B-permit after leaving
Sorry, but it doesn't work that way. Unless you have a job here or are independently wealthy enough not to need to work you can't extend/renew a permit. Basically no job, no permit. Even if your permit was valid for a few months, the fact you're no longer employed by a Swiss employer makes the permit invalid.
If you want to come back you'll either need to find a new employer or get a tourist visa.