In the study of dynamics on networks, moment closure is a commonly used method to obtain low-dimensional evolution equations amenable to analysis. The variables in the evolution equations are mean counts of subgraph states and are referred to as moments. Due to interaction between neighbours, each moment equation is a function of higher-order moments, such that an infinite hierarchy of equations arises. Hence, the derivation requires truncation at a given order, and, an approximation of the highest-order moments in terms of lower-order ones,known as a closure formula. Recent systematic approximations have either restricted focus to closed moment equations for SIR epidemic spreading or to unclosed moment equations for arbitrary dynamics. In this paper, we develop a general procedure that automates both derivation and closure of arbitrary order moment equations for dynamics with nearest-neighbour interactions on undirected networks. Automation of the closure step was made possible by our generalised closure scheme,which systematically decomposes the largest subgraphs into their smaller components.We show that this decomposition is exact if these components form a tree, there is independence at distances beyond their graph diameter, and there is spatial homogeneity. Testing our method for SIS epidemic spreading on lattices and random networks confirms that biases are larger for networks with many short loops in regimes with long-range dependence. A Mathematica package that automates the moment closure is available for download.