Fixes NPE when writing to disconnected client, Issue #2577

In every situation I have tested, checking if the client is active before writing to the client prevents the NPE message but does not change the functionality.  I have not been able to create an instance where the act of calling the write method before checking if the client is active has the effect of changing the active() method to return False when it would have otherwise returned True.