Window context manager now handles excepitons properly