Probably because the callback is in a different thread. The main workaround is to completely terminate the application using Environment.Exit(1);
To call the close function in the user interface thread, you should use:
wfRuntime.WorkflowTerminated += (se, ev) => { // call back to the window to do the UI-manipulation this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { this.Close(); })); };
source share