Viviani finished fourth behind Caleb Ewan (Lotto Soudal), Arnaud Démare (Groupama-FDJ) and Pascal Ackermann (Bora-Hansgrohe) on stage 11 in Novi Ligure, after again failing to connect with his Deceuninck-QuickStep lead-out train.
He won four stages and the points jersey in last year's race but has frustratingly finished second three times this year and was relegated from victory on stage 3 to Orbetello after race judges ruled he move across the road.
Viviani was hoping to finish the Giro d'Italia in his hometown of Verona but bravely went on Italian television to confirm he was heading home early.
"My Giro ends today," Viviani said, his team soon confirming his departure.
"I'm not at my best and lack the self-belief that I need. I'll head home and soon start working for the second half of the season. There's no point in carrying on in the hope of finding something that never seems to arrive."
Viviani seemed unable to pinpoint why he was struggling to win sprints after racking up 21 victories since he joined Deceuninck-QuickStep in 2018.
"I'm happy to meet the public at the start in the morning, but then in the race, it's clear there's something wrong. I can't be satisfied with three second places and a win that was declared not a win. The team and I were aiming for a lot more," he said.
"I've heard so much talk in the last ten days but it's not about my form, it's more about my head. I haven't been doing 'my' sprints. Instead, I jump left and right, following other people … I'm missing Morkov in my lead-out train. My teammates and I look for each other and then lose each other, so we end up not sprinting as we'd like. That's not how I usually do the sprints, and so it's hit my self-confidence. I've got to switch off so that I can start all over again and get back to winning."
Viviani is on Deceuninck-QuickStep's long list for the Tour de France, but the Belgian team also hope to target the general classification with Enric Mas and have to find opportunities and support for Julian Alaphilippe and Phillippe Gilbert. They could opt to select Fabio Jakobsen or Alvaro Hodeg for the sprints.
Viviani is also out of contract at the end of the 2019 season, with team manager Patrick Lefevere admitting he is struggling to cover all the salaries and bonuses of his successful team.
Viviani promised to fight back.
"I've been knocked down a lot of times, and I've always got up again, important victories will come again sooner or later. It's just not my Giro," Viviani concluded.