Perform closing the frontmost document of the application.

This method emulate pressing closing button if possible. When it is failed obtaining closing button, key type "Command+W" is emulated.

Some application does not reflect emulation of pressing closing button. For such application, "Command+W" emulation can be forced by passing true to set_keytype_emulation.