App.Current.Shutdown()
is not working asynchronously according to documentation:
http://msdn.microsoft.com/en-us/library/ms597013.aspx
Application.Current.Dispatcher.BeginInvokeShutdown()
is working async.
UPD
I've tested your code. You are right. And documentation about App.Current.Shutdown()
is misleading. Code after App.Current.Shutdown()
in current method will be executed. Therefore App.Current.Shutdown
should be the last statement before return (and also respecting method call tree).
As alternative to call Environment.Exit(0)
but it could be considered as trick and hack, because in the fact it terminates process either gracefully or not, when gracefully isn't possible.