Mark Cavendish couldn't hide his delight as he won stage five of the Giro d'Italia after a close finish in Fano on Thursday.