In order to stay in the U.S. to complete your Green Card Processing, after your current status has expired can only usually be done if you are an Immediate Relative (minor child, husband, wife or parent of a U.S. Citizen). If you are not an Immediate Relative you usually have to return to your home Country to complete the process but there are exceptions depending on each person's particular situation.
However if you overstayed (your current Visa expired), once you leave the U.S. you may be barred from entering the U.S. for 3 or 10 years depending on the length of time you stayed in the U.S. after your Visa expired. That is why it is so important that you check with an Immigration Attorney before you leave the U.S.
Learning what your rights are under the law is the best way to find a solution to your problem and what you need to do to solve your problem.
In regard to the 3 and 10 year Bars, you have to apply for a special waiver which is not easy to get. Your situation would have to show extreme hardship to your U.S. Citizen/Green Card Spouse or Parent in most cases.
There may be other options depending on your situation such as what year you arrived here, when the petition was submitted, your particular country of origin or if you were a minor child when one of your parents became a U.S. Citizen as well as other situations too numerous to mention.
Please contact a licensed Immigration attorney before you act on your specific situation. Immigration Laws and Federal Regulations are constantly changing and the general information provided can change over time.