added terminate method to application