Fix for issue #3042: incorrect shutdown in embedded mode
Merge pull request #3043 from PhantomYdn/issue3042

Fix for issue #3042: incorrect shutdown in embedded mode