Close message stream early.

For things like edit_job_codes() to work properly we should tear
down the message resource before we start tearing down the bits
and pieces of the JCR (and mig_jcr). Hopefully we don't trigger
to many deadlocks this way but this seems to be a severe design
flaw in which important state information is destroyed when you
might still want/need it.