Close memory object.