How to close the connection with a GPIO pin