Updated exit function, should be functional as it was checked out from 34fb5006 before code was removed