diff -u src/event_stubs.c src2/event_stubs.c
--- src/event_stubs.c	2007-04-20 16:33:55.000000000 +0300
+++ src2/event_stubs.c	2007-04-20 16:14:37.000000000 +0300
@@ -195,6 +195,21 @@
   CAMLreturn(Val_unit);
 }
 
+CAMLprim value
+oc_exit(value timeout_float) 
+{
+  CAMLparam1(timeout_float);
+  struct timeval timeval;
+
+  set_struct_timeval(&timeval, timeout_float);
+  
+  if((0 != event_loopexit(&timeval))) {
+    uerror("exit", Val_unit);
+  }
+
+  CAMLreturn(Val_unit);
+}
+
 
 CAMLprim value
 oc_event_dispatch(value unit) 
diff -u src/libevent.ml src2/libevent.ml
--- src/libevent.ml	2007-04-20 16:32:47.000000000 +0300
+++ src2/libevent.ml	2007-04-20 16:33:43.000000000 +0300
@@ -101,6 +101,9 @@
   Hashtbl.remove table (event_id event);
   cdel event
 
+(* Exit within n seconds *)
+external exit : float -> unit = "oc_exit"
+
 (* *)
 (* Not fully implemented yet *)
 external pending : event -> event_flags list -> bool = "oc_event_pending"
diff -u src/libevent.mli src2/libevent.mli
--- src/libevent.mli	2007-04-20 16:33:55.000000000 +0300
+++ src2/libevent.mli	2007-04-20 16:11:24.000000000 +0300
@@ -74,6 +74,9 @@
 
 val pending : event -> event_flags list -> bool 
 
+val exit : float -> unit
+(** [exit timeout] Terminate the main loop within timeout seconds *)
+
 (** {5 Process Events} *)
 
 val dispatch : unit -> unit
