Ensuring that multiple closes do not get executed