Starting from the second law of thermodynamics applied to an isolated system consisting of the system surrounded by an extremely large medium, we formulate a general non-equilibrium thermodynamic description of the system when it is out of equilibrium. We then apply it to study the structural relaxation in glasses and establish the phenomenology behind the concept of the fictive temperature and of the empirical Tool-Narayanaswamy equation on firmer theoretical foundation.