Advance Parole in a Nutshell
When you're applying to adjust status to permanent residency, you need to also apply for advance parole if you anticipate traveling outside of the United States before your permanent residency is granted. If you travel outside of the United States without advance parole while your case is pending, then your case will be denied for abandonment and you have to refile your adjustment of status all over again, and pay the fees all over again! While you're waiting for your adjustment of status case to be decided, you are allowed to travel within the United States and directly to U.S. territories (like Puerto Rico, U.S. Virgin Islands, Guam), but you bear the risk of your plane getting diverted to another country in the case of foul weather or something else.
If you need to get advance parole at the last minute, you can emergency advance parole by scheduling an Infopass appointment, filling out the advance parole form, and going to a USCIS Field Office to physically submit the application and fee, and then you can get a stamp in your passport. One thing to keep in mind though is that the Infopass appointments are usually scheduled for two weeks out.
If you want to learn more about advance parole, you should talk to an immigration attorney.