Fix on-close recursion