Pre-WWII why was Germany trying to detain & imprison Jews vs just letting them leave?

In many stories of Jewish immigrants to the US coming from Europe in the pre-WWI era there are stories of those that got out and immigrated, and on the other hand those that got left behind and went to the work camps and death camps.

What was Germany doing with respect to their Jewish citizens in that era? If they didn’t want Jews around why were they expending the huge effort and resources to catch them and put them in camps, and ultimately kill them. Why wouldn’t letting them leave be more productive for everyone?

The problem wasn’t so much that Germany prevented Jews from leaving; it was that difficult bordering on impossible for them to take any money or property out of Germany with them, and very few countries were willing to accept Jewish refugees (particularly poor ones). The Nazis even signed an agreement with the Jewish Agency allowing Jewish immigrants to Palestine to convert some of their assets to German industrial goods which sold in Palestine. Even then Jewish immigration was still hampered by British quotas, and Arab violence. Then WWII started and Jewish Emigration become totally unfeasible (& many of the Jews that did get out ended up in other Western European countries, like the Franks). Nazi policy didn’t fully shift to total extermination until 1942.