Process SIGINT and SIGTERM only in safe places

When closing st-term by CTRL+C usb connection doesn't closed properly if signal interrupts usb-related functions.