Close A Neovim Window With The API

June 2021
-- doesn't force close
vim.api.nvim_win_close(WINDOW_ID, {})
-- forces close
vim.api.nvim_win_close(WINDOW_ID, { force=true })
-- (get the id with `vim.api.nvim_set_current_win()`
-- Closes the window (like |:close| with a |window-ID|).

nvim_win_close({window}, {force})  


Attributes: 
    not allowed when |textlock| is active

Parameters: 
    {window}  Window handle, or 0 for current window
    {force}   Behave like ``:close!`` The last window of a
              buffer with unwritten changes can be closed. The
              buffer will become hidden, even if 'hidden' is
              not set.
end of line