Try adding explicit exit to prevent hanging