# Closing

The Popup provides events which facilitate common use cases such as closing the component [after leaving the viewport](https://www.telerik.com/kendo-angular-ui/components/popup/closing#after-leaving-the-viewport) and [on document or `Esc` click](https://www.telerik.com/kendo-angular-ui/components/popup/closing#on-document-click-or-escape).

## After Leaving the Viewport

The [`anchorViewportLeave`](https://www.telerik.com/kendo-angular-ui/components/popup/api/popupcomponent#anchorviewportleave) event is triggered when the anchor is scrolled outside the screen boundaries. When the anchor is not visible, use `anchorViewportLeave` to close the Popup—otherwise, it will remain visible within the screen boundaries.

> When the container is scrolled, the Popup will not close automatically. To control the [visibility](https://www.telerik.com/kendo-angular-ui/components/popup/hidden-state) of the Popup, explicitly set its hidden state.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/popup/closing/leaving-viewport/source.txt)

## On Document Click or Escape

To close the Popup when the user clicks outside its boundaries, wire the `document.click` event and determine whether the Popup was clicked. If clicked, the Popup remains open.

> When the container is scrolled, the Popup will not close automatically. To control the [visibility](https://www.telerik.com/kendo-angular-ui/components/popup/hidden-state) of the Popup, explicitly set its hidden state.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/popup/document/source.txt)

## Suggested Links

* [API Index of the Popup](https://www.telerik.com/kendo-angular-ui/components/popup/api)
* [API Reference of the PopupComponent](https://www.telerik.com/kendo-angular-ui/components/popup/api/popupcomponent)
* [Troubleshooting `AnimationBuilder` Error in Standalone Components](https://www.telerik.com/kendo-angular-ui/components/troubleshooting/general-issues#when-i-try-to-load-a-kendo-ui-for-angular-component-in-a-standalone-component-an-error-occurs)
