Sometimes called an Advance Medical Directive, a living will allows you to state your wishes in advance regarding what types of medical life support measures you prefer to have, or have withheld/withdrawn if you are in a terminal condition (without reasonable hope of recovery) and cannot express your wishes yourself.
Oftentimes a living will is executed along with a Durable Power of Attorney for Healthcare, which gives someone legal authority to make your healthcare decisions when you are unable to do so yourself.