There are two forms of ModeShapeEngine.shutdown(...) - which are you calling.
Note that these methods return a Future<Boolean>. If you want to block until the repository is shutdown, you need to call "get()" to wait until the engine is shutdown or "get(long,TimeUnit)" to wait at most the specified time until the engine is shutdown.
The garbage collection process runs using this "modeshape-cron-*" thread every 5 minutes. By chance does Tomcat shutdown after 5-6 minutes? If so, that'll help narrow down the issue.
which actually returns without any delay, but after 20 min tomcat still hangs.
Okay, great. I'll reopen the issue, and we'll try to fix it ASAP.
The problem turned out to be an invalid namespace prefix (see MODE-1655), which prevented the repository from starting up properly, and which prevented the repository from shutting down properly. Fixing the namespace prefix problem corrected the issue.