Why do people say suicide is a sin?

I thought the quote “thou shalt not kill” in the Bible only refers to illegal killing.

Suicide is not illegal in most countries. Suicide is illegal in a small amount of countries.

Wouldn't this mean if a person succeeds in killing themself in a country where suicide is legal it wouldn’t be a sin?

Updates
+1 y
Even attempting suicide but not being successful is still not a crime in most countries
Why do people say suicide is a sin?
Post Opinion