The occupation is the cause of the violence. The violence cannot possibly end without the occupation ending first. You cannot stop the effect, without first stopping the cause.
The occupation is an excuse for violence. It is not the cause of the violence. Its a convenient soundbite used by anti-Israel folks to shift responsibility entirely to Israel so Arab Palestinians and their "supporters" don't have to require anything from the Arabs -- even with something as simple as a cessation of violence.
The CAUSES of the violence in Gaza right now, especially, are multiple:
1. The deeply held belief system of Arab Muslims that the Jewish people have no rights to sovereignty over any of the territory. This is a complex mix of religious beliefs, widespread antisemitism and the rejection of Jewish history and Jewish indigeneity.
2. A strongly ambivalent, at best, or non-existent, at worse, desire for an independent, wholly Palestinian State as a complete and separate from #1 above combined with a resistance to be seen as culturally distinct from Syrians and Jordanians. Neither can West Bank Palestinians and the Gazan Palestinians find it in themselves to either bring the halves together in a mutual State nor to fully separate themselves into distinct nations.
3. The desire to return to specific locations, which is intimately tied to point #1 and point #2 where the intention is deny Jewish sovereignty and Jewish self-determination and not to be assimilated into a Jewish State in those places.
4. Continued sense of a lack of agency in development of their own future which is caused primarily by inept and corrupt governments and an overall lack of vision.
5. The redistribution of resources to violence instead of toward economic health.
None of these issues can be solved by Israel "ending the occupation". In fact, as we saw with Gaza, "ending the occupation" lead to an intensification of all of these issues.
And, just to give you the other point of view, the CAUSES of the Israeli "occupation" are also multiple:
1. First and foremost it is NEVER. EVER. AGAIN. The Jewish people will never again permit themselves to be indiscriminately or deliberately slaughtered. Neither in the homeland nor in the wider Diaspora. Security and safety take precedence over everything else.
2. The Jewish people seek a national identity where the culture is primarily Jewish. Where the Jewish people are free to live Jewish lives. There is nothing immoral about this goal. Not every nation needs to be a melting pot. Most countries in the world are firmly established on the premise of a distinct ethnic culture. And most modern wars are predicated on this stance.
None of these issues can be solved by Israel "ending the occupation".