Fixed bug that caused the program to not terminate