Which ROMs are you experiencing problems with when this script is running? I’m using the same poweroff circuit, but I haven’t put any serious play time into any one ROM yet so I’m wondering what triggers it.

You could potentially try sleeping longer than one second to check the status of the pin. Maybe bump it up to like 10 seconds or so. Yes, your shutdown could take 10 seconds longer to complete, but that would probably be worth it if it didn’t interfere with your game play.