How to terminate connections to shared PCs?
I don't know why this PCs are showing up in the shared computer


They are showing up because they have a zero configuration network service like Bonjour or mDNS enabled that is responding to broadcasts from your Mac.


  I never tried to connect to this PC then how did the connection happen


As stated in the comments by Steve Chambers if you have guest access enabled on the client, it will immediately connect when you select it.  This is not a problem.  If you want to turn this functionality off, disable guest access on the client itself.


  so my question is how can I remove this PCs and terminate the
  connection


You can't really "remove" this PC because it's working as expected.  Your Mac is broadcasting a "request" for all networks nodes with a zero configuration protocol to respond and that PC does.  What you are seeing is a list of computers that your Mac has found (not necessarily connected to).  It's very similar to Windows "Network Neighborhood" where you can see the computers on your network subnet.

The connection will terminate after a few minutes of idle activity.