If you leave your employer before your I-140 is approved, one of two things can happen: 1) the employer which filed the I-140 petition for you can allow it to be processed to completion, in which case you will be allowed to keep your priority date (a big deal); 2) the employer who filed the I-140 petition for you can ask USCIS to withdraw the petition before it is approved, in which case you will not be allowed to keep your priority date (a big bummer).

Even if the I-140 petition has been approved, the employer which filed it can ask USCIS to withdraw the petition. The good news is, unless the petition was fraudulently approved (you provided false information, like a fake diploma), the priority date is yours to keep for life.

If at all possible, I would delay your departure from an employer who has an I-140 pending for you until after the petition has been approved.