The inheritance rights of relatives end with the grandparents, and the inheritance then goes to the canton and the municipality of residence. Single persons without legal heirs can decide for themselves to whom they want to leave their assets. If they fail to stipulate who should inherit what, after death all property will pass to the canton and, depending on the canton, to the municipality of residence.
For single persons, it is very easy to use assets philanthropically as a gift or bequest from their estate. This generally applies to anyone who does not need to consider compulsory heirs (spouses and descendants). In the case of large fortunes, it may even make sense to set up a foundation.
You should make sure that your will is clearly worded. It must evidently state which person or institution is to be a beneficiary and with what amount or share of the inheritance. In a worst-case scenario, wills requiring interpretation could be declared invalid by the court.