A tight battle for the final podium spot ended in heartbreak for Sergio Perez and Carlos Sainz as both collided and finished the race in the barrier.