use correct pointer to be closed