Pakistani authorities have said an insurgent attack on a train carrying hundreds of people has ended, with all attackers killed following a day-long standoff.