Fix invalid state, which happen if signals raise exception