1. First, try best to find another job as soon as possible. you have Opt until December.
2. talk to company to delay withdrawing H-1 application for 1 or 2 month, usually the company won't withdraw the application immidatelly, but just in case they do. Try to explain to company the situation( you need h1 qutoa, since company already paid application fee, for the company, it doesn't matter for withdrawing later.) your h1b application should be almost done if applied in May. Have the copy of h1b applciation receipt or copy of h1 approve notice( if company can give to you) for later h1b transfer.
2. talk to company to delay withdrawing H-1 application for 1 or 2 month, usually the company won't withdraw the application immidatelly, but just in case they do. Try to explain to company the situation( you need h1 qutoa, since company already paid application fee, for the company, it doesn't matter for withdrawing later.) your h1b application should be almost done if applied in May. Have the copy of h1b applciation receipt or copy of h1 approve notice( if company can give to you) for later h1b transfer.