Added safe_quit function to wrapper.