- moved autoreconnect task into onclose handler
added null dom check