 	}
 	
 	// MARK: - NSPopoverDelegate
-	public func popoverDidClose(notification: NSNotification) {
+	public func popoverWillClose(notification: NSNotification) {
 		guard let popover = notification.object as? NSPopover else { return }
 		if popover.contentViewController === dateRangePickerController {
 			dateRangePickerController = nil
+			updateSegmentedControl()
 		}
 	}
 }

		segmentedControl.setLabel("▶", forSegment: 2)
		segmentedControl.action = "segmentDidChange:"
		segmentedControl.autoresizingMask = [.ViewNotSizable]
		(segmentedControl.cell as? NSSegmentedCell)?.trackingMode = .Momentary
		segmentedControl.target = self
		self.addSubview(segmentedControl)
		

		
		let nextAllowed = dateRange.next().restrictToDates(minDate, maxDate).endDate != dateRange.endDate
		segmentedControl.setEnabled(nextAllowed, forSegment: 2)
		
		// Display the middle segment as selected while the expanded date range popover is being shown.
		(segmentedControl.cell as? NSSegmentedCell)?.trackingMode = dateRangePickerController != nil ? .SelectOne : .Momentary
		segmentedControl.selectedSegment = dateRangePickerController != nil ? 1 : -1
	}
	
	// MARK: - ExpandedDateRangePickerControllerDelegate
