refactor some code into new method as it is useful in several places
decent behaviour when closing entire project from menu