Modified stop function