exit logic