The rest of the code uses Detach to "close" a proc.Process, the tests should do the same. Any cleanup that proc.Process needs to do can then be put inside Detach and the tests will run it.