Does withdrawal of cap-exempt H1-b cancels OPT status?

I am currently working with my STEM OPT EAD and my current employer filed for my cap-exempt H1-b which is till in process. If I decide to join another employer now with my existing STEM OPT and my current employer withdraw the petition (i129), will it revoke my current STEM OPT status? My STEM OPT is valid until July 2023.

N.B. asked a lawyer and he said it will cancel OPT since i129 form has been received by USCIS already.

Your OPT status will end as of H1B effective start date on the I-797/I-94 as your H1B is cap-exempt. Otherwise with cap-subject, the effective start date is 1st October.
You can tell your H1B employer to withdraw and assuming USCIS will take action hopefully before it is approved, you can continue on OPT.

If OPT status ends with the application of cap-exempt H1-b, how does withdrawing petition help?

You misunderstood my answer. Your OPT end from the start date for I-94 attached to the H1B approval notice. Just filing of H1B petition will not end your OPT, it needs to be approved with I-94 that will have a start date on it.

Thank you! Appreciate your response.