Change algorithm for waiting for message

A MessageListenerContainer shouldn't close the ApplicationContext
in a message listener (it will cause the connection to be dropped and
the message to be unacked). The fix is to wait on a latch and close
the context in the main application thread instead.

Fixes gh-4