Properly handle connection state and add .connection_stale function

The `on_close` and `on_error` events now properly set the connection
state to 'disconnected'.

I also added a .connection_stale() function for easily checking whether
or not the connection is active.