The former foreign and home secretary announced he was quitting the shadow cabinet to run for City Hall.