With the default settings, the modal dialog uses an iframe to display the content. That means the content is working with a different window context.
In order to open the modal dialog, you need to include daypilot-modal.js from https://code.daypilot.org/81367/daypilot-modal. The latest version is 2.5 but one of the older versions can be included in a specific tutorial/demo. It's recommended to use the latest version so you have access to the latest API.
There are two ways to close the modal dialog:
1. From the parent window (that one which opened the modal dialog):
DayPilot.ModalStatic.close();
2. From the modal dialog itself:
Method 1 - reach the parent context:
window.parent.DayPilot.ModalStatic.close();
No extra libraries are needed, the parent context already has access to daypilot-modal.js.
Method 2:
Include daypilot-modal.js in the modal page itself and call:
DayPilot.Modal.close();
3. If the modal page is an ASP.NET WebForm you can use the server-side helper (DayPilot.Modal.cs from https://code.daypilot.org/81367/daypilot-modal) and call Util.Modal.Close() on PostBack. This will complete the PostBack and close the modal dialog.