Melvin,
I promised to let you know results of my experiment, so here is goes:
tcp_keepalives_idle = 900
tcp_keepalives_interval=0
tcp_keepalives_count=0
Doesn't terminate connection to database in 15 minutes of inactivity of psql prompt. So, it looks like that would work only for case if network connection is broken and session left hanging. For psql prompt case looks like pg_terminate_backend() would be the only solution.
Thanks,
Oleg