Fixed handling of system signals when waiting for a new message from the queue. Close #178