Shut down of macOS takes forever

Solution 1:

The comment from @DavidSupportsMonica to try safe mode brought me on the right track. The problem did not occur with safe mode. As suggested here, I created a new user account with which the problem also did not occur.

Fortunately I remembered having registered jack to be started at boot, which turned out to be the culprit: jack simply won't stop. I guess at some point the shut down process reaches a timeout and just turns the machine off.

I've created an issue with brew-services.