To ensure that all destructors are properly called if the program is terminated from keyboard (Ctrl+C), the approach with signals are used: