The Yang-Mills gradient flow in finite volume