Added client closing to prevent leaks