Close a report

How can we close a report using X++ code??

Can you please explain in what scenario you would need to close a report using code?

Suppose if i give a checkbox on dialog where we can specify whether to print details of employee or not if we don’t check that checkbox then the report will be close after a sleep of 5 seconds.