<p>Wrote the following in PowersHell as a quick iTunes demonstration:</p>

<pre><code>$iTunes = New-Object -ComObject iTunes.Application
$LibrarySource = $iTunes.LibrarySource
foreach ($PList in $LibrarySource.Playlists)
{
  write-host $PList.name
}
</code></pre>

<p>This works well and pulls back a list of playlist names.
However on trying to close iTunes a warning appears</p>

<blockquote>
  <p>One or more applications are using the iTunes scripting interface. Are you sure you want to quit?</p>
</blockquote>

<p>Obviously I can just ignore the message and press [Quit] or just wait the 20 seconds or so, but is there a clean way to tell iTunes that I've finished working with it?</p>

<pre><code>Itunes 7.7.1, Windows XP
</code></pre>

Here is one thing that I did on my a Powershell script that adds podcasts to iTunes. I use Juice on a server to download all the podcasts that I listen to.  The script uses .Net methods to release the COM objects.  When I wrote my iTunes script I had read a couple of articles that stated you should release your COM objects using .NET.
```
```
[void][System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$LibrarySource)
    [void][System.Runtime.InteropServices.Marshal]::ReleaseComObject([System.__ComObject]$iTunes)
```
```
I also run my scripts the majority of time from a shortcut, not from the powershell prompt.
Based on your comments, I did some testing and I determined that I would get the message when running against iTunes, if I ran my script in a way that leaves powershell running.  iTunes seems to keep track of that.  Running the script in a manner that exits it's process after running, eliminated the message.
One method of running your script from powershell, is to prefix your script with powershell.
```
```
powershell .\scriptname.ps1
```
```
The above command will launch your script and then exit the process that was used to run it, but still leaving you at the powershell prompt.