Remove center-of-mass velocity to a group of atoms

Hi everyone
If I have a channel full of water, and I imposed a thermal gradient in the walls.
In order to avoid artifacts from thermal expansion or thermal waves on the walls due to the thermal impulse associated with the activation of the imposed thermal gradient at the beginning of the NEMD simulation, I would like to remove the the mean
center-of-mass velocity of the water after 5 ns of activated the thermostat.
How can I do this?

This should be easily possible using equal and atom style variables.