Mark Cavendish was denied a chance of victory in stage two of the Tour of Slovenia by a crash in the closing stages that Luka Mezgec win the stage.