Moved sucket.closed statement