set correct restoreCursor state in case of exception