The preview window doesn't respond to setting its visibility to false, so currently
it can't actually be closed without using the task manager or another external way
of closing windows.
Fix the issue by triggering the window's close() function instead.