Added cleanup function called when received a signal.