Prevent it. There are various ways to prevent wandering. Try engaging the person and distracting him/her if he/she wants to go out. Lock the door, or mask the exit. You will get more information at http://www.Alz.Org/care/alzheimers-dementia-wandering.Asp#tips.
Have awake care. This is both common and difficult. The answer for any one person may be unique to them. The safest thing is to have 24/7 awake care. This can be impossible in a home setting. Make sure the person has an id bracelet on so that if they do get lost, someone can help return them to home. One can install alarms on the doors and windows. Call a local support group or your doctor for suggestions.