How to layer/composite multiple images using imagemagick (convert)

In order to layer two images a.png and b.png using convert, use this syntax:

convert a.png b.png -composite out.png

In order to layer three images a.png, b.png and c.png using convert, use this syntax:

convert a.png b.png -composite c.png -composite out.png

In order to layer four images a.png up to d.png using convert, use this syntax:

convert a.png b.png -composite c.png -composite d.png -composite out.png         

In general, you need to list the first two input images without -composite, and then list every other filename including the output filename using -composite.