Way back when the carnival game prizes weren't child oriented, they were for the adults and the most common prize was cigars. So when a person would come close to winning but fall short it was said, "Close but no cigar." ( source ) Today the phrase has nothing to do with carnival games and cigars but the meaning is the same. When you come close but don't quite get there...