Moment closure is a method originating from statistical physics for finding low-dimensional mean-field models of dynamics on networks. It proceeds by deriving moment equations, expressions of the evolution of mean counts of subgraph states. Each moment equation for a given subgraph depends on mean counts of larger subgraphs, for which new equations need to be derived. To avoid an infinite system of equations, one relies on a closure scheme, a substitution of counts of the largest subgraphs by an expression involving counts of smaller ones, which is justified by an independence assumption. This approach leads to an exact description with few equations if the independence assumption is valid for sufficiently small subgraphs, such as in case of epidemic dynamics on trees without reinfection, but the mean-field models obtained in this way still approximate the dynamics well on networks with few short loops. A higher prevalence of loops requires increasing the order of the moment closure. Yet, no systematic method exists to obtain higher-order moment equations and the closure scheme required to truncate them. In this paper, we present a general method to obtain and truncate moment equations, applicable to any model of dynamics on networks with at most interactions between nearest neighbours and for arbitrary approximation order. We first obtain the moment equations in their general form, via a derivation from the master equation. Then, we show that closure schemes can be systematically obtained via a decomposition of the largest subgraphs into their smallerdiameter components, and, that this decomposition is exact when these components form a tree and there is independence at distances beyond their graph diameter, offering a theoretical justification for moment closure on non-tree networks. Applying our method to the SIS epidemic model on lattices and random networks, we find that the well-known long-range correlation near the epidemic threshold due to a continuous phase transition only leads to considerable bias in lower-order moment closures for low-dimensional lattices, because here, presence of loops of all sizes prevent decomposition of larger-distance correlations in terms of smaller-distance ones, unlike in random networks. Our method extends the practical applicability of moment closure to networks in which clustering due to a high density of short loops is particularly important. A Mathematica script that automates the moment closure is made available for download.