Eight-time premier class world champion Marc Marquez concluded his MotoGP career with a second-place finish at the Valencia Grand Prix, won by Aprilia's Raul Fernandez.