Improve client closing behaviour

Send closing frame and close connection when all refereences to
the client are deleted
Read the FIN bit