re-work stale connection cleanup (fix handling for tornado 1.x)

There was a problem with connection close being called back directly which caused
the dictionary of connections to change while iterating.