Better handling for process exit