TransCanada Corp. shut part of its Keystone oil pipeline system after a 5,000-barrel leak in South Dakota, the company said on Thursday, four days before neighboring Nebraska was set to decide on the company's long-delayed Keystone XL pipeline.