Unxpected exception


Sometimes when I use ShowDialog method I get an exception in Close() method after line
Application.Current.RootVisual.GotFocus -= new RoutedEventHandler(this.RootVisual_GotFocus);
is executed. IOW it happens while exiting from sb.Completed delegate.
It's "Value does not fall within expected range" exception. I think this bug dependent on time because when I try to debug this line it doesn't happen.
Exception details:
StackTrace " at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)\r\n at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName, Object[] rawData)\r\n at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element, UIElement visual)\r\n at System.Windows.UIElement.TransformToVisual(UIElement visual)\r\n at System.Windows.Controls.FloatableWindow.UpdatePosition()\r\n at System.Windows.Controls.FloatableWindow.OnOpened()\r\n at System.Windows.Controls.FloatableWindow.Opening_Completed(Object sender, EventArgs e)\r\n at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)\r\n at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)" string
Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
I think it happens when window is not opened yet and I call Close method. So the "open_animation" is still running and is completed after "close_animation". It's my intuitive assumption but I'm almost sure that it's right.