In an electric car, the horn runs from the 12V battery, same as the lights, so they will work when the car is off (the main battery is disconnected). In a gasoline-powered car, everything runs off a 12V battery anyway, and will work without the engine running.