Gravitational closure of matter field equations