If you find you need to leave your Guild or Team for any reason, just go to your Guild or Team page and scroll all the way to the bottom. There you will find a "Leave" button that you can press. It will ask you to confirm and then you will be out of your Guild or Team.
Alternatively, from the members page, you can tap your own name and choose to leave the guild that way.
If you are the Leader of your Guild or Team then when you leave, whoever was there longest will become Leader after you are gone.