Rework disconnect code to work more reliably
Rework disconnect code to work more reliably

benjamin9999/pika,skftn/pika,renshawbay/pika-python3,zixiliuyue/pika,Tarsbot/pika,fkarb/pika-python3,jstnlef/pika,shinji-s/pika,vrtsystems/pika,hugoxia/pika,knowsis/pika,vitaly-krugl/pika,Zephor5/pika,pika/pika,reddec/pika