Exit function functionality implemented