Trapping exit signals and allowing starting as an application