add application run and stop hooks