Refactor sys_halt for better times