fixed possible NPE
added sample of exit and restart of applications