Mazda said it is to end production of its RX-8 sports car with a rotary engine in June next year, nearly half a century after it began selling rotary-engine vehicles.