I can't find a link to an article from the 90s, but there was an article where a Bonanza pilot died in flight (due to health issues), his plane came smoothly down in a field somewhere due to the autopilot keeping the wings level after it ran out of gas. So as long as the plane has electric power, many autopilots will function when the engine stops.