Fix logic for closing store