title: Can't close Form in Powershell when using fuction
body: <p>I'm trying to throw up a control-less window in Powershell that hovers on top while the script is still executing.  Once the remaining is code is finished, I want to remove the control-less window.</p>
  
  <p>I've got everything down except how to remove the window itself.  $Form.close() doesn't work, and if I had to guess it's because it can't access $Form in the function.</p>
  
  <p>So I'm at a loss.  How do I remove the window?</p>
  
  <pre><code>function goForm
  {
  Add-Type -AssemblyName System.Windows.Forms
  $Label = New-Object System.Windows.Forms.Label
  $Label.AutoSize = $True
  $Label.Text = "This form is very simple.  
  In some cases, it will be larger.
  
  And have spaces.
  
  Like this."
  $Form = New-Object System.Windows.Forms.Form
  $Form.Text = "Progress"
  $Form.SizeGripStyle = "Hide"
  $Form.AutoScroll = $True
  $Form.AutoSize = $True
  $Form.AutoSizeMode = "GrowAndShrink"
  $Form.MinimizeBox = $False
  $Form.MaximizeBox = $False
  $Form.Controlbox = $False
  $Form.WindowState = "Normal"
  $Font = New-Object System.Drawing.Font("Times New Roman",12,   [System.Drawing.FontStyle]::Regular)
  $Form.Font = $Font
  $Form.StartPosition = "CenterScreen" 
  $Form.Controls.Add($Label)
  $Form.Topmost = $True
  $Form.Add_Shown({$Form.Activate()})
  $Form.ShowDialog()
  }
  
  start-job $function:goForm
  
  Start-Sleep -m 5000
  
  $Form.Close()
  
  [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  $oReturn=[System.Windows.Forms.Messagebox]::Show("The other window should be gone." , "")
  </code></pre>