clearing memory on clsoe