A long-running battle over plans for a controversial sand and gravel quarry in Lancashire has come to an end.