If your U.S. citizen spouse has died, it is still possible to get permanent residence in the U.S. (a "green card") through "adjustment of status," without leaving the country. See U.S. Citizen Spouse Died: How Do I Get a Green Card on My Own? for a discussion of who is eligible for a green card via this method. This article will focus on the application process for obtaining that green card while living in the United States.
There are certain requirements for you to adjust status in the United States, and those don't change even if your spouse has died. (See Who Can Apply for a Green Card Through Adjustment of Status.)
One of those requirements is that U.S. Citizenship and Immigration Services (USCIS) approve a petition classifying you as the spouse of a U.S. citizen. This may be either a petition filed by your spouse (Form I-130) or one that you file on your own (Form I-360), as described next. In either case, however, you will need to show that you were indeed married to a U.S. citizen.
If your spouse filed an I-130, Petition for Alien Relative for you before dying, the agency will normally (whether it's been approved or not yet), convert it to an I-360, Petition for Amerasian, Widow(er), or Special Immigrant upon learning of the spouse's death. (This latter petition is used by and for many types of people; in your case, it's for a "widow(er).")
You'll want to let USCIS know about your spouse's death by sending a letter to the office handling the I-130 petition, along with a copy of the death certificate. You won't need to do anything else. If the I-130 petition has already been or is ultimately approved by USCIS (see Eligibility for a Green Card as the Widow(er) of a U.S. Citizen), you have satisfied the requirement of having an approved petition.
If USCIS had already approved the I-130 petition and you were already in the process of applying for adjustment of status when your spouse died, USCIS will continue to process your adjustment of status application and you do not need to file another one.
If your spouse did not file an I-130 petition for you before dying, you will need to get an I-360 petition filed with and approved by USCIS. For help, see Filling Out USCIS Form I-360 Self Petition as a Widow(er) of a U.S. Citizen. You must file the I-360 no more than two years after the death of your spouse, and you must not remarry.
You can file the I-360 petition either before or at the same time as your adjustment of status application. If you're eligible to adjust status right now, it's easier to file the I-360 and adjustment application together.
As the widow or widower of a U.S. citizen, you apply for adjustment of status by preparing Form I-485, Application to Register Permanent Residence or Adjust Status," as well as supporting forms and documents. The process is the same as it is for all other people who are applying for adjustment of status, with one important exception.
You (and any of your children adjusting status with you) are not required to submit "Form I-864, Affidavit of Support." This is a form that the person who petitioned for an immigrant usually must give to the government, promising to support the immigrant financially in case he or she can't be self-supporting. In your case, the government knows that you petitioned for yourself, and it won't require that you prove you can support yourself.
Instead, however, you should file a Form I-864W, showing that you're exempt from this requirement.
If you originally entered the U.S. when unmarried, on a K-1 fiance(e) visa, then when you got that visa, you were supposed to marry your spouse within 90 days of coming to the United States. If you did that, and then your spouse died, you can still adjust status.
You don't need to file any special form. On the I-485 adjustment of status application in Part 2, you place a check in the third box under 1.a, "admitted to the U.S. as a fiance(e) ..."
If your fiance(e) died before you were able to marry, you cannot adjust status, because you were never the spouse of a U.S. citizen. Also, if you stay in the U.S. and marry someone else, you can't adjust your status based on that marriage. The rules say that K-1 visa holders can't adjust status as the spouse of anyone except the person who petitioned for the K-1 visa. So if you remarry, you will have leave the U.S. and get your immigrant visa through a U.S. consulate in your home country.