Fix setjmp problem and abnormal termination after some time