Fábio Vieira scored the winner as Hamburg came from behind to beat Frankfurt and all but secure their top-flight status for another year.