C# check if a process exists then close it
<p>I'm trying to Close a process within C# but how do I check if is open first?  Users asked for this feature and some of them will be still using the close button of the other process.</p>

<p>So, right now works fine:</p>

<pre><code>Process.GetProcessesByName("ProcessName")[0].CloseMainWindow();
</code></pre>

<p>Now, how do I check first that it exists, this doesn't work:</p>

<pre><code>if ( Process.GetProcessesByName("ProcessName")[0] != null ) {...}
</code></pre>
