This is an example that presents the way - how to kill the processes in MSBUILD script.It's very useful when you need to shutdown some application or services - to prevent the script from failing because the running processes are locked .I use well known OS command "Taskkill" with two arguments /F (Specifies to forcefully terminate process) and /IM (Specifies the image name of the process that has to be terminated. Wildcard '*' can be used to specify all image names).
<Project DefaultTargets = "Kill"
<!-- List of processes to kill -->
<Process Include="Process1.exe" />
<Process Include="Service1.exe" />
<Process Include="Engine1.exe" />
<Target Name = "Kill">
<Exec Command="taskkill /F /IM %(Process.Identity)" IgnoreExitCode="true" />