as long as USCIS receive your H1b transfer application BEFORE the day your current h1b expires, you are OK. You can submit I-140 at any time. However you must have a valid status or at the very least a valid stay in the US to be eligible to file I-485.
big bless! Is your current and next job both H1b? my understanding is that it does not matter for H1b when to submit the eb1a. but for whether you can still legally stay in the US for the gap, not so sure.
as long as you are still get paid as the LCA states, maintaining the same title, it is fine. However in case they would not pay you, you might consider use your annual leave or so.