python bot now detects when the socked is closed