why the sleep breaks even though TERM is handled.
you are handling a TERM signal for the whole perl program. You have not written any specific code to handle a TERM signal, while sleep function is in progress.
Signal handling is a general concepts with regard to the OS you are working on. To learn more about what is signal, signal handling and so on, you can refer
UnixSignals. If you want to learn more still google helps you out.