Safe shutdown/reboot from GPIO pins

Hassio on my ras pi has been locking up and requiring a reboot. Would it be possible to have an option to attempt a safe shutdown or reboot if a gpio pin is connected to a negative? I know I can ssh in but sometimes I can’t even get into that. I hate pulling the power if I can avoid it.