adding close command when the program ends