title: GUI-button to exit loop, Move-Item Job
body: <p>I'm struggling to break the <code>while</code> loop when the "Off" button is being pressed. 
  Instead, after starting the moving process, I am running into an endless loop.</p>
  
  <pre><code>$objForm.Controls.Add($StartButton)
  $objForm.Controls.Add($OffButton)
  
  $OffButton = New-Object System.Windows.Forms.Button
  $OffButton.Location = New-Object System.Drawing.Size(340,105)
  $OffButton.Size = New-Object System.Drawing.Size(90,28)
  $OffButton.Text = 'Off'
  $OffButton.Name = 'Off'
  $OffButton.Font = [System.Drawing.Font]::New("Microsoft Sans Serif", 11)
  $OffButton.Add_Click({$script:AktiveLoop = $False})
  $objForm.Controls.Add($OffButton)
  
  $StartButton = New-Object System.Windows.Forms.Button
  $StartButton.Location = New-Object System.Drawing.Size(340,135)
  $StartButton.Size = New-Object System.Drawing.Size(90,28)
  $StartButton.Text = 'Start'
  $StartButton.Name = 'Start'
  $StartButton.Font = [System.Drawing.Font]::New("Microsoft Sans Serif", 11)
  $StartButton.Add_Click({
      $script:AktiveLoop = $true
  
      while ($script:AktiveLoop -eq $true) {
          Move-Item $source -Destination $destination
          Start-Sleep -Seconds 1.0
  
          if ($script:AktiveLoop = $False) {
              break
          }
      }
  })
  [void] $objForm.ShowDialog()
  </code></pre>