Electron energy-loss spectroscopy of quasi-two-dimensional crystals: Beyond the energy-loss functions formalism