Corrected exit behavior.
Split core exit behavior into a separate class. Added success/cancel handlers.