Legally you're obligated to pay the lease until the end of the term unless you find someone else to take over the lease. Even death doesn't get you/your heirs out of paying the rent.
If you lose your job, the best thing to do is give notice as required and work hard to find a replacement tenant. In German that's called a nachmieter. I don't know the term in French or Italian. A replacement tenant is someone who agrees to take over the existing lease including length of lease and costs.