refine close_connection