Before your priority date becomes current, your I-485 will not be approved. You can stay in US legally as long as your I-485 is pending even if you lose your job.