Catching sigterm and err to restore cursor