Added a loop to resend close command