Added on_stop() handling