He was promoted to captain in December 1778, and served as brigade inspector of the Pennsylvania Brigade, his experience making him a good choice for drill instructor. He subsequently served as commissary general under General Arthur St. Clair, though he preferred to serve in the field with his regiment. His unit, being well-disciplined, did not participate in the mutiny of the Pennsylvania Line in January 1781. The Pennsylvania troops were reorganized and Ziegler was present at the surrender of Cornwallis at Yorktown in October 1781. After Yorktown Ziegler accompanied his regiment to South Carolina to serve under General Anthony Wayne. With the end of the war, Ziegler retired from the army on January 1, 1783. Unsure about what he was going to do with his life, he openly wept during the final review of the troops by General Nathanael Greene.