refactorin: moved exit related stuff into a separate module