Albert Einstein's theory of relativity shows that energy and mass are the same thing, and that neither one appears without the other. Thus in closed systems,both mass and energy are conserved separately, just as was understood in pre-relativistic physics.
The new feature of relativistic physics is that "matter" particles could be converted tonon-matter forms of energy, such as light; or kinetic and potential energy. However, this conversion does not affect the total mass of systems, because the latter forms of non-matter energy still retaintheir mass through any such conversion.
Today, conservation of “energy” refers to the conservation of the total system energy over time. This energy includes the energy associated with the rest massof particles and all other forms of energy in the system. In addition, the invariant mass of systems of particles is also conserved over time for any single observer, and is the same value for allobservers.
Therefore, in an isolated system, although matter and "pure energy" can be converted to one another, both the total amount of energy and the total amount of mass of such systems remainconstant over time, as seen by any single observer. If energy in any form is allowed to escape such systems, the mass of the system will decrease in correspondence with the loss.
A consequence ofthe law of energy conservation is that perpetual motion machines can only work perpetually if they deliver no energy to their surroundings.