General Motors is recalling nearly 780,000 compact cars in North America because the engines can shut down unexpectedly and cause crashes. The company says six people have been killed in crashes related to the problem.

The recall affects Chevrolet Cobalts and Pontiac G5s from the 2005 through 2007 model years.

U.S. safety regulators say the weight of the key ring and rough roads can move the ignition switch out of the run position, cutting the engine and electricity. If that happens, air bags may not work.

GM says there have been 22 crashes from the problem. All were off the road and happened at high speeds.

Dealers will replace the ignition switch for free. GM says owners should remove non-essential items from key rings until the problem is fixed.