Fix bug on cleanup when SIGTERM received