I am using Android Studio "Jsch" package to connect my Android Device to my Raspberry Pi via SSH. The Event "on press" sends a command,which executes a Python file on my Raspberry Pi. This File turns on the light for 2 minutes, via GPIO-Ports. Thereafter the light turns off. But if my device is disconnected from the Jsch Session the light doesn't turn off, because the Raspberry Pi terminates the Pyhton Scrpit. To execute The file with nohup or screen is not an option. I would like that the light immediately turns off, if the Connection is lost.
Thank You for Help!
Edit1: Thanks to Mark Smith. With The Signals it was possible to finally cleanup the GPIO ports without any problems.