Two potential explanations:
1) You don't have a pull-up on your mega168's reset line, so the programmer is functioning as your pull-up and allowing your mega168 to run. When you disconnect the programmer, the board randomly resets. I've seen this happen before.
2) You are inadvertently powering your mega168 via your programmer (one of the ISP lines is Vcc) and are inadequately powering your mega168 otherwise, so it only has the power it needs to run while your programmer is connected. I expect this is not the case, but why not mention it?
- Ben