Sometimes, some rogue queries can take too long to execute. If the queries are blocking in nature, i.e., they restrict access to a table while they are executing, then any other query on the same table will be put on hold, and this leads to a pile-up of queries. This can, depending on your DB load, even cause the max connections to be exceeded. Luckily, you can easily kill long queries in pgAdmin.
Go to Dashboard in your pgAdmin. At the bottom, in the Server Activity section, under the Sessions Tab, you can see all the Active queries.
Now, notice the cross button and the Stop button to the left of each query.
By clicking on the cross button, you terminate the session itself, while on clicking on the Stop button (black square), you cancel the active query.
It is recommended to click on the cross button itself, especially if your database has breached the connection limit and you need to terminate connections to the database.