making sure process is shutdown properly