Out-GridView locks WinForms script

Hello, I have a PSH script that uses Windows Forms elements. Part of that script is a functionality that when you press a button, it continuously reads a log file and displays it in Out-GridView control.

Sample (stripped of other code):

$ButtonShowLog.Add_Click( {
   Get-Content -Path "C:\tmp\testlog.txt" -Wait | Out-GridView -Wait -Title "Log view"
})
This works, however when I close the Out-GridView window, the app is hung and doesn't react to anything and cannot be closed by regular means. I have to kill the process in task manager (use the Debug - Stop in VSCode), upon which I get .NET exception message:

************** Exception Text **************
System.Management.Automation.PipelineStoppedException: The pipeline has been stopped.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
at System.Management.Automation.ScriptBlock.InvokeAsDelegateHelper(Object dollarUnder, Object dollarThis, Object[] args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Any idea how do I fix this, so I can close the Out-GridView window and continue working with the forms app/script?

Why are you doing this?..

Get-Content -Path "C:\tmp\testlog.txt" -Wait | Out-GridView -Wait -Title "Log view"

… there only needs to be one wait.

You should not being doing this wait twice.
You may want try this differently. Example:

# View live log - only new log entries
Get-Content -Path $LatestLog -tail 0 -Wait | 
Out-GridView -PassThru -Title $LatestLog