Check the D+ connection on the alternator. The lamp has 12v supply to it and when the engine is not running an earth connection is provided via the alternator which operates the lamp. When the alternator is running then the earth is replaced by 12v so the lamp has 12v on each side and goes out.