If you have accrued enough credits, you will not be denied benefits except under some circumstances. You will be able to collect Social Security benefits even if you move to a foreign country after you retire.
Your benefits will be suspended if you move to any of these countries but you can collect those withheld payments later once you move to an unrestricted country.
If you are serving time in prison, your benefits may be suspended during that time, however, the general rule is that felons can receive their benefits after being released.