Operating semiconductors outside of Voltage specifications?
LEDs don't switch, so there if there is a series resistance there is never 340V across them, it's all dropped in the resistor. When a transistor switches off, effectively the whole voltage will be across it.

Having overlooked voltage ratings of a 2N2222 and 2N2907 recently, across a 100V+ DC supply, I recently got a dramatic explosion-

Why Did My NPN/PNP Voltage Regulator Experiment Explode?