Added exception handling for clients closing window