Prevent potential double-close issue