The government in the key oil-producing Canadian province of Alberta has reached a deal to divest its crude-by-rail programme at a cost of C$1.3 billion (US$981 million), it said.