The battle of Jericho ended when God brought the walls of the fortified city down after nearly seven days under an unusual Israelite siege. Then, there was great carnage as the soldiers of Israel cut down young and old. It's disturbing.
So the people shouted, and the trumpets were blown. As soon as the people heard the sound of the trumpet, the people shouted a great shout, and the wall fell down flat, so that the people went up into the city, every man straight before him, and they captured the city. Then they devoted all in the city to destruction, both men and women, young and old, oxen, sheep, and donkeys, with the edge of the sword. Joshua 6.20-21 (ESV)
While I don't propose that the disturbing nature of what happened can simply be explained away, I think it's important to recognize the historical facts of the matter and allow that to frame any conclusions we would make.
First off, this was not genocide. This was in no way a version of "ethnic cleansing." Jericho was a military objective and it had to be dealt with before Israel could move past that gateway city into the land that had been promised to their forefather Abraham.
Second, I would note from the biblical account that surrender or escape were clearly options available to the citizens of Jericho before the walls fell. We know from Joshua 6.1 that the city was on lock down before Israel arrived because there was an acceptance there that an attack was imminent. We also know that the people of Jericho recognized the danger (Joshua 2.9-11). Consequently, Rahab (and her family) did surrender to Israel and were saved. The terms Rahab was able to negotiate with Israel on behalf of her family are recorded in Joshua chapter 2.
In the days leading up to the climactic battle, there is no reason to believe that residents of Jericho could not have safely evacuated.
Third, the holy God of Israel needed to bring judgement against this Canaanite people. Their society trafficked human beings, practiced child sacrifice, and used cultic prostitution as part of their worship practices. Suffice it to say, these weren't your Rotary Club/PTA good neighbors. One might imagine it being better to be dead than to have to live in a society where your child could be offered to a pagan God in sacrifice or your daughter turned into a sex slave at the worship center for a local god. These are just good things to keep in mind when considering the events of Joshua 6.
Finally, I will confess personally, I do find the violence at Jericho disturbing. Maybe that’s you as well. In places like this, as a person of faith, I choose to trust in God’s wisdom. He has a MUCH bigger and more complete vision of history than I do. He’s a good God, and I don’t feel qualified to sit in judgement of a single event like this based on my limited understanding. Also, I know that the culmination of God's story isn't the annihilation of sinners, but the salvation of sinners through the sacrifice of his only begotten at Calvary.
His love is greater than I can ever grasp. His wisdom and understanding are beyond mine. I choose to trust him EVEN when I don't fully understand.