As far as I know you cannot know if a process has a debugger attached to it outside of the process itself. In .NET you can, however, check on your current process if it is attached to a debugger or not using the "Debugger.IsAttached" property located in System.Diagnostics.
You can then use the the following code to kill your process:
Process.GetCurrentProcess().Kill();
To kill the current process.