add Application.ApplicationExit handler to prevent resource occupied