The lattice-Boltzmann method (LBM) and its variants have emerged as promising, computationally efficient and increasingly popular numerical methods for modelling complex fluid flow. However, it is acknowledged that the method can demonstrate numerical instabilities, e.g., in the vicinity of shocks. We propose a simple and novel technique to stabilise the lattice-Boltzmann method by monitoring the difference between microscopic and macroscopic entropy. Populations are returned to their equilibrium states if a threshold value is exceeded. We coin the name Ehrenfests steps for this procedure in homage to the vehicle that we use to introduce the procedure, namely, the Ehrenfests idea of coarse-graining. The one-dimensional shock tube for a compressible isothermal fluid is a standard benchmark test for hydrodynamic codes. We observe that, of all the LBMs considered in the numerical experiment with the one-dimensional shock tube, only the method which includes Ehrenfests steps is capable of suppressing spurious post-shock oscillations.