Rotate the mirror on its base like you would for parking in a tight space or something. There is a hidden socket head cap screw (allen).
When you remove that the mirror comes straight up out of the holes in the door until you reach the end of cable travel. The removal procedure depends on whether or not you still have door glass and or whether you are leaving any of the harness in the door. If you are stripping the car just remove the entire harness with the mirror from the outside. If you are keeping the mirrors then remover the connector shell (plastic part) by withdrawing the pins from it. There is a special AMP tool that you push in from the front of the connector face to unhook the pins from the plastic. Once you have done that then withdraw the mirror from the harness. If you are removing the passenger's side one please be careful removing the harness and then email me for my address :)
Jay has the method down. There are a couple of things to add.
On the older mirrors when removing the glass to get at the motor and plug it is easy to break off the clips. Prior to the 87 with the memory and the ring, the mirror glass pushes into some plastic grommets on the mounting plate. I have found that using 1 inch putty knife is the best way to release the mirror from the backing plate.
The two wires that attach to the back of the mirror for the heater are also easy to break. Weather gets into the connections and pulling on them will cause the connections to break off the mirror. I use a pair of pliers to grip them and give them a little twist first. Sometimes the insulation will break off. This is a good place to use a little liquid electric tape.
The bolt holding the mirror in place can get frozen with rust. I find applying a little Liquid Wrench to the bolt a couple of hours before attempting to remove it works well.
Dan the Pod Guy
Old style and new style flag mirror. The GTS style (cup) is similar to the S4 in terms of attachment