He was still a member of Parliament, and returned as parliamentary leader in 1939. However, only months before the next election was scheduled, Norway was invaded and subsequently occupied by Germany as a part of World War II, effectively suspending the Parliament. In December 1940 Madsen was arrested by the Gestapo. He was imprisoned at Møllergata 19 until 15 May 1941. In August 1942 he lost his job as stamped paper administrator, and between 16 November 1942 and 16 May 1943 he was imprisoned for the second time, serving time at Bredtveit concentration camp and Åkebergveien. He did not recover his civil job until 8 May 1945, the day of the liberation. He had also been a member of the board of the Bank of Norway since 1930, but this was suspended during the German occupation.