@Samy ********
technically as soon as you are unemployed, whatever date that is.
If it's under good terms, the employer can make the date a little later to help.
Once the permit is canceled (usually immediately)as the employer is cutting ties, you have to leave.
If you leave without canceling the extension, you may not get caught for overstay or anything.
However if you ever try to get another non-b you could have issues including fines and denial.
If you return just as a tourist you will likely be okay, but you never know.
If you don't do it correctly you roll the dice.