So long, Tony Stewart

Nope. These guys are not employed by NASCAR, and NASCAR has no say about what types of legal extracurricular activities they participate in. Could a driver's contract with his employer, a race team, state "no racing outside of NASCAR", or similar? I think it could, but I don't think I've ever heard of such a thing.

There are many sports related contracts out there that limit outside activities. No motorcycles, no sky diving, etc. Depends on the sport and the investment ($$$$$$$$$$) of the employer and other investors (sponsors).