Fix bug with popen and application restart