Fixed bug with programs not shut down properly