The siege of a school in Pakistan by Taliban militants has ended, leaving at least 141 people dead, most of them students.