If the power button stops working ,how can I get my phone to turn off

I know that my phone is old but it still has its memory and that is why I am going to figure this out. I've tried everything an the only thing that worked was charging it an stating it in safe mode but what happens the next time I let the battery die ? I don't want to take that chance and find out the hard way that I can never get it back to life I mean on I will have lost everything so please if you know the answer or have a solution share it with me please

crwdns2934089:0crwdne2934089:0 crwdns2934093:0crwdne2934093:0

crwdns2934109:0crwdne2934109:0

crwdns2889612:0crwdne2889612:0 0
crwdns2934285:0crwdne2934285:0