Great Britain's Davis Cup campaign ended in a 2-0 semifinal defeat to Spain, closing Leon Smith's 17-year tenure as captain.