Pakistan has indefinitely closed two border crossings with Afghanistan after opening them for two days to let through Afghans with visas, officials said.
The official border crossings were abruptly closed last month after a series of attacks Pakistan blames on militants sheltered in Afghanistan, heightening tension between the neighbours.
But Pakistan temporarily reopened the crossings on Tuesday and Wednesday, to allow the return home of stranded citizens of both countries holding valid travel documents.
Two men, a woman and a child were trampled to death in the resulting surge of more than 20,000 Afghans passing through the crossings, a government spokesman said.
Pakistani official Niaz Mohammad, based in the border town of Torkham, said 24,000 Afghans had returned to Afghanistan on foot, while 700 Pakistanis returned home, before the border was closed again.
"There is no clarity on when the border will be reopened," Mr Mohammad said.
The closure chokes off a key trading route for landlocked Afghanistan, although it has been working to build trade ties with other neighbours, such as Iran. It also cuts off Pakistani traders from a steady market.
On Thursday, about 200 traders and transporters held a protest at Torkham, complaining that cargo on 800 stranded trucks was rotting, particularly meat and fruit.
"People have suffered billions of rupees of losses in the past three or four weeks," said one protester, Ali Jan, a transporter.
"Their loaded vehicles have been standing by the road and there is no indication when the border will be opened."
A Pakistani government official, who asked not to be named, said the border would stay closed until Afghanistan took action against a list of 76 "most-wanted terrorists" whose capture and handover by Kabul the Pakistani military demanded last month.
Relations between the two countries are tense, with each routinely accusing the other of doing too little to stop Taliban fighters and other militants from operating in its territory.