If you are laid off before the end of your H1B job, your employer is obligated to pay the reasonable cost of your return home.

If an employer does not fulfill that duty, the employee can complain to the U.S. Department of Labor. To avoid unlawful presence, the employee should see what emergency assistance is available through their own nation's embassy or consulate, as most nations have emergency assistance programs for stranded travelers.