I had a similar issue just recently and none of the fixes mentioned anywhere worked.
First thing was to figure out exactly what clicking "Leave the homegroup" does. I opened Process Monitor, added a filter to include results from explorer.exe (as that's the process that spawns the control panel window) then started capturing. Clicking on
that link caused explorer.exe to create a new thread then destroy the thread with nothing in between, so I disabled the filters and saw that it was calling svchost.exe. svchost.exe then traversed the registry until it hit a snag. One registry key was giving
an access denied error.
HKEY_CLASSES_ROOT\CLSID{C90250F3-4D7D-4991-9B69-A5C5BC1C2AE6}
Instead of fiddling with permissions, I exported that key, deleted it, then re-added it, and lo and behold, no more access denied error. After this, I did the usual routine of stopping the three Peer* services, deleting the C:\Windows\ServiceProfiles\LocalService\AppData\Roaming\PeerNetworking
folder, then restarting said processes. This time, clicking on Leave the homegroup worked as intended. With a few more tweaks (disabling and stopping the two HomeGroup services), any mention of HomeGroup in the navigation pane in Explorer was gone.
Ironically, starting the HomeGroup Listener service still gave me some about
%%-2147023143. But nevertheless, I'd fixed my issue so all was well.
When in doubt, bust out Process Monitor.