-> To get the active sessions use this query.
cmd:select usename, pid, datname from pg_stat_activity;
to know the active sessions
-> Now we can see the active sessions if we want to close all the connections to the particular database then use the cmd.
cmd:
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = ‘test_db’;

kill the sessions
-> After the execution of this cmd we need to restart the application server to activate the session.