Stop Queries

pg_cancel_backend
Terminate query but keep connection.

pg_terminate_backend
Terminate query and the connection.

How to use:

SELECT pg_cancel_backend(1234567);
SELECT pg_terminate_backend(1234567);

Before you terminate, understand what it is doing.

You can find pid in pg_stat_activity.