clean up memory structs on close()