Disabling WinRM - Removing Listeners

Hi group,
I am trying to disable WinRM remotely and it looks good except the section where I remove the Listeners a message pops up regarding connectivity to the server (PC) was lost. I believe the listeners have been removed by then.
‘Network Connection Interrupted. Attempting to reconnect for up to 4 minutes.’
Any ideas will be greatly appreciated.
Regards, Gideon.

Write-host "Remove Listeners"
Invoke-Command -ComputerName ESS-XXX-REP -ScriptBlock {
Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse
pause
}

Please do not post images of code or error messages as they are usually not helpful. Instead post the plain text and format it as code.

Thanks in advance