Well, many people complain about this problem. There are many suggestions about using pull-down resistors to solve the problem but reality act is you have to experiment rather to calculate correct pull-down resistor value on each different occasion.
In my beginners tutorial (code files, forum, wiki) I am showing few different ways to solve this problem in way that is more predictable. Up to now, we have seen how to use Relay with PNP transistor switch and interesting SCR thyristor approach. There will be few more on the way. This may not be very intriguing for advance audience but for beginners is a perfect way to learn. Following schematics are teaser for what is coming into next version of the tutorial: using a NAND logic gate.
NOTE: Appears the shown schematics mislead few people to think that those are “ultimate” solutions that I am proposing. This is not the case. These ones are just extracts from the tutorial text. There are not necessarily solutions of the global problem and they are far away from ultimate. They are partial and contextual ones that make sense only when you read the tutorial. Only then, they make sense as they are part where a digital logic gates are introduced to the beginner. And yes, there will be better ways to solve the problem at more global level than LED switch (in fact the tutorial already contains two methods shown) and they will show later, so please be patient, beginners need time to learn some stuff before jump into the advanced techniques 🙂