I am re-posting your question in the Immigration section because I believe it will recruit more thorough responses for you. From an employment law perspective, there is typically no problem with working as an employee for one company and an independent contractor for another, so long as there is no contract that prohibits it (from either company) and you are not violating relevant trade secret laws (which exist even in the absence of a specific contract).
Nevertheless, I realize this response does not address your visa question, which is why I am re-posting.
I wish you luck.
H-1B status requires employment, and it is a violation of your H-1B status if you work as an independent contractor. Also, your employer (Company A) would be in violation of its Labor Condition Application (LCA) obligations if it does not pay you on a regular payroll (and can be penalized by the Wage and Hour Division of the Dept. of Labor).
You can work for two employers at the same time, as long as you have an approved H-1B petition for each (or have an AC21 right to work), and are an employee of each. So if Company A can keep you on the payroll, and treat you as an employee, you can continue to work for them until they can find a replacement.
This is only a preliminary response to an inquiry, based on incomplete information. Helpful advice and counsel can only be provided after you have discussed your case with Mr. Bach, he is familiar with all of the circumstances of your case, and the advice is provided in writing. Any opinion provided here should not be relied upon for any purpose. No attorney/client relationship is formed until you have formally retained our law firm to represent you. We are not responsible for any action or lack of action you take based on this preliminary response.