It's true. Shelled peanuts are permissible at NASCAR events, but specimens still encased in their fibrous jackets are universally frowned upon in motorsports. In fact, a lot of concession stands at racing venues won't even sell them; but even if they are available, most drivers will not allow peanut shells in the pits. They're bad luck.
According to Snopes, the urban legend experts of the Internet, two separate incidents (both in 1937) are widely blamed for the peanut ban. In the first incident, at Langhorne Speedway (near Langhorne, Pa.), two vehicles strayed off the road, seconds apart, both injuring or killing spectators. At the Nashville fairgrounds later that year, four or five cars collided, resulting in the death of one driver. In both incidents, witnesses claimed that peanut shells were prominently visible in the wreckage, even though official reports mentioned nothing of the sort. Other documentation dates back before the 1937 crashes. It's actually somewhat logical: Before World War II, car races mostly took place at local fairgrounds, where peanuts were a popular treat. Even at state and county fairs today, peanut shells tend to get scattered everywhere. So inevitably, peanut shells would end up in or near the cars, and if a crash occurred, the shells were to blame. Obviously.