I am writing coded ui tests and I have the application open if it is not already open. Then if one of them fails I close the application the thing is I have multiple tests in mu
Perhaps what you're looking for is the TestCleanup attribute?
EDIT: Also, if you want to run something after all tests have been run, the AssemblyCleanupAttribute might be more appropriate.