Refactors main.c exit condition