CB-5021 Make it safe to call close() multiple times