Using Popen directly but not getting termination as we want