layout.ejs: Fix bug when canClose is undefined
refactored startup process