Move trap_exit to the beginning of the init call.