Nancy Pelosi, who has represented San Francisco for nearly 40 years, announced her decision in a video Thursday.