If your employment is terminated
If you are in Sweden with a work permit as an employee and are laid off or terminate your employment yourself, there are no longer any grounds for granting you a work permit. This means that your permit can be revoked.
If the employment on which a permit is based is terminated, in practical terms this means that there are no longer any grounds for granting a residence permit. This means that the permit can be revoked.
If you are in Sweden, have started your job, and want to continue working in Sweden, you have three months to find a new job before your permit is revoked. If you find a new job within three months, you need to apply for a new permit for it. If you apply before your previous permit expires, you can continue to work while you wait for your new decision. Any family member with a valid permit on the basis of their ties to you may also remain in Sweden for as long as you are allowed to remain here and have a valid permit.
Click here for more information about what applies when employment is terminated