Fixed bug that stopped process from properly closing