Confusion with the definition of an closed system I read that in a closed system, Energy can flow in or out but mass remains constant. But, we know that E=mc^2 i.e if energy changes, mass must change! 
So whats going on in here? Where did i get it wrong?
 A: The term "closed system" is an idealized system which never exists in the real world.  We use them because many systems respond very similarly to a mathematically perfect closed system.
Because it's an ideal, not a real thing, we have to give it a definition, and it's up to the speaker to ensure the listener understands that definition.  For example, in many cases, "closed system" means neither mass nor energy escapes the system.  The term is also used in cases where the mass or energy escaping the system is well quantified, such as the system you describe where mass cannot enter nor escape but energy can.
A good example of this might be a refrigeration cycle.  The mass within the refrigeration equipment never changes, but energy and heat are transferred through the system, pulling heat out of the refrigerator into the environment.  In reality, the system is not perfectly closed.  Mass actually does escape from refrigeration equipment, which is why you sometimes have to recharge them.  However, the mass loss here is so small that much of the behavior of the refrigerator can be captured by assuming no mass leaves.  Only when you're looking at the long term reliability of the fridge do these losses matter.
Relativistic effects also happen to not matter very much for many systems, like our refrigerator.  Yes, in theory we could see some difference in "relativistic mass" due to changes in energy, but they are incredibly small compared to all other sources of error in the system.
If you wanted to, you could define a closed system which accounts for the relativistic effects of its parts.  It just turns out that this makes the equations far more complicated and the benefits from doing so are minimal.  If you developed a refrigeration circuit which relies on relativistic effects to efficiently cool your food, then you would be obliged to include that in your definition of "closed system."
In practice, you will find that your ergodic assumption and your assumption of equilibrium will typically become more important than your non-relativistic definition of a closed system for a remarkably large number of systems you will look at.  However, you'll find that we do make the assumptions just the same, because they tend to be useful.
