I would recommend creating a custom action in your setup project to override the OnBeforeUninstall() function, and cancel it in there. Something along these lines:
protected override void OnBeforeUninstall(IDictionary savedState)
{
base.OnBeforeUninstall(savedState);
if(Process.GetProcessesByName("nameOfYourProcess").Length > 0)
{
throw new InstallException("Cannot uninstall while appname is running.");
}
}