Depending on the amount of data your WSUS Installation collects over time, it's not uncommon to see errors / timeouts when trying to clean up the WSUS database.

As an example: Running Invoke-WsusServerCleanup -CleanupObsoleteUpdates (PowerShell) gives you an Error like The underlying connection was closed



One option to address this error is to increase the timeout in Internet Information Services (IIS) Manager. To do so, open Internet Information Services (IIS) Manager from Control Panel - Administrative Tools, select the WSUS site on the left-hand Section and chose on the right-hand action pane Configure Limits...
Adjust Connection Time-out in the opened dialog to a more appropriate value for your environment.



After that change, re-run the PowerShell command to clean up your WSUS database (or use the Server Cleanup Wizard in the GUI).