Function removeEndingVertexFromGeometry