If you have a closed system, the number of moles will remain the same.
Think about a balloon, if you fill it with a gas and tie the balloon closed with a knot, you will have a closed system for a while assuming the gas cannot escape immediately.
Increase the pressure on the balloon by squeezing it, decreases the volume.
Increase the temperature, increases the volume.
The number of moles will remain constant.