STOP button for delay()

Hi, can you help me with my question? I have to power a small device on pin 2. So after start signal the pin 2 is set to high. Then the program delays for given time (device is powered and works). After this time the pin 2 is set to low and device is off. I would like to have a security butron "stop" in order to be able to stop the device when something happens. But I don't know why. In my simple code:

 digitalWrite(pin2,HIGH);
 delay(time);
 digitalWrite(pin2,LOW);

how can I do that? During the delay(); the arduino cannot read from console that I am sending a signal.. or not? what to do with that?

Blink without delay.

ok :)