Close connection only after processing current message
Merge branch 'master' into clean_close